Hi everyone! I have here a question...
Sprite has a event handlers like this:
function mySpriteClass:init()
self:addEventListener(Event.ADDED_TO_STAGE, self.onAddedToStage, self)
self:addEventListener(Event.REMOVED_FROM_STAGE, self.onRemovedFromStage, self)
end
function mySpriteClass:onAddedToStage()
self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
end
function mySpriteClass:onRemovedFromStage()
print("check for removed")
self:removeEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
end
function mySpriteClass:onEnterFrame()
print("do somethimg")
end |
After performing
stage:removeChild(mySprite) |
sprite disappears form screen well and the text "check for removed" printed, but sprite still remains in memory. So the
mySpriteClass:onEnterFrame() |
will continue to execute end "do somethimg" continues printing.
How to completely remove sprite from memory?
Comments
https://deluxepixel.com
So I do check like this after performing stage:removeChild(mySprite)
before you remove it?
https://deluxepixel.com
I developed mySpriteClass with ZeroBraneIDE in live coding mode.
Even a full stop and restart Gideros Player did not solve the problem.
But when I close ZeroBrane and restart again - everything ran as it should :-)
Looks like a ZeroBrane bug, this whole hour blown my brain!
Thanks for the help anyway!
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Sounds like a bug.
https://deluxepixel.com
I'd love to know why it was done this way? Is there any advantage?
Likes: SinisterSoft, MoKaLux
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Likes: PaulH