This is the constructor from my hero.lua file
function hero.new(startingTile) -- constructor local newhero = { who = "hero", frameNumber = 1, displayHero = nil, lastIdlePos = "idleUp", pos = startingTile, heroSequenceData = { { name="idleUp", start=3, count=1, time=3000 } , { name="idleDown", start=6, count=1, time=3000 } , { name="idleRight", start=9, count=1, time=3000 } , { name="idleLeft", start=12, count=1, time=3000 } , { name="runUp", start=3, count=3, time=400 } , { name="runDown", start=6, count=3, time=400 } , { name="runRight", start=9, count=3, time=400 } , { name="runLeft", start=12, count=3, time=400 } , { name="random", frames={ 3, 9, 6, 12 }, time=300 } } } return setmetatable( newhero, hero\_mt ) end
Here’s the code from my other lua file :
char = hero.new(1) char.displayHero = display.newSprite( heroSheet, char.heroSequenceData ) char.displayHero.xScale = tileDimension / tileDefaultSize char.displayHero.yScale = tileDimension / tileDefaultSize char.displayHero.x = tileArray[1].displayTile.x char.displayHero.y = tileArray[1].displayTile.y char.displayHero:setSequence(char.lastIdlePos) char.displayHero:play() char.displayHero.parent = char print (char.displayHero.parent) -- table : 00ED7A70 local test = char.displayHero.parent print (test.who) -- nil print (char.who) -- hero