It looks like you're new here. If you want to get involved, click one of these buttons!
Parent = Core.class( Sprite ) function Parent:init( myLayer ) self.child1 = Sprite.new() self.child2 = Sprite.new() self:addChild(child1) self:addChild(child2) myLayer:addChild(self) end function Parent:destroy() self.child1:removeFromParent() self.child2:removeFromParent() --[[ Are the two lines above required in this case ??? ]]-- self:removeFromParent() self = nil end |
Comments
The way @hgvyas123 demonstrates is the easiest way to accomplish what you want.
Even more, you don't have to nil out self, but rather the variable where you stored the instance if you had one, if not then only remove from parent