It looks like you're new here. If you want to get involved, click one of these buttons!
Game = Core.class(Sprite) function Game:init() function onRemovedFromStage(sprite) print ("------------------------------------------------- "..sprite.name.." REMOVED FROM STAGE") end _mySprite1 = Sprite.new() _mySprite1.name = "Sprite1" self:addChild(_mySprite1) _mySprite1:addEventListener("removedFromStage", function() onRemovedFromStage(_mySprite1) end) _mySprite1:removeFromParent() _mySprite2 = Sprite.new() stage:addChild(_mySprite2) _mySprite2.name = "Sprite2" _mySprite2:addEventListener("removedFromStage", function() onRemovedFromStage(_mySprite2) end) _mySprite2:removeFromParent() end game = Game.new() |
------------------------------------------------- Sprite2 REMOVED FROM STAGE |
Dislikes: Yan
Comments
However, "Sprite1" isn't part of the scene tree because it's not added to the stage and its parent isn't either. If you included "stage:addChild(self)" before "self:addChild(_mySprite1)" then the event would trigger.
I have failed to describe my issue.
For now I am using the scene manager that is shipping with most of the Gideros examples (ebook) and is given as a resource for beginners for best practices.
I am transitioning to another scene manager but I have to make it work for a project that I had from "the past".
So - with the scene manager shipped with Gideros - , it doesn't seem to work.
I don't understand : if sprites added as child to each Class (page) are displayed on screen, that means that the page is added to the stage.
Please find the files attached (I have modified Page0 to include the removeFromParent() code and that's it).
At least I wanted people to know about it (unless it's another mistake that I have made?), it can be confusing for those of us who use the SceneManager and assume that .
(I'm not suggesting that this is the solution; it's just for debugging.)
So
I just found out about it (tried with a timer).
Thank you
Yes sure, I meant that I was using a timer just to test and this made me understand (one second before I got notified by your answer that the error had to do with removing after the init.
thanks for the help.
Likes: ar2rsawseen