It looks like you're new here. If you want to get involved, click one of these buttons!
Player = Core.class(Sprite) function Player:init(name) self.myName = name self.myBag = Inventory.new() self:addChild(self.myBag) end Inventory = Core.class(Sprite) function Inventory:init(name) self.items = {} --print(self:getParent().myName) -- give error 'attempt to index a nil value' Timer.delayedCall(1000, function() print(self:getParent().myName) end) -- output 'John' end local firstPlayer = Player.new("John") stage:addChild(firstPlayer) |
Comments
Likes: jimlev
for the 4547 times, thx a lot ar2rsawseen ! (I'm not really sure if there is more of my code or of yours in my game...)
Likes: ar2rsawseen
SinisterSoft: “ I don't create classes that much - classes are good for making things simpler but imho for frame rate they are also death by a thousand cuts.”
Totebo: “ Best quote ever.”
🤔