It looks like you're new here. If you want to get involved, click one of these buttons!
cemevin
Member
Scene1 = gideros.class(Sprite) function Scene1:init(data) --Timer.stopAll() local tmr = Timer.new(1000, 1) tmr:addEventListener(Event.TIMER, function() print("scene1") --this is a predefined function in main.lua which calls scenemanager:changeScene(...) changeScene("scene1") end) tmr:start() self:addEventListener("exitBegin", function() Timer.stopAll() end) end |
Comments
I believe init is only supposed to be called once on initial scene creation, so you should do stuff to initialise your vars etc in enterBegin, so this is expected behaviour.
This is from a doc I downloaded a while ago...
Events supported by Scene manager are:
• enterBegin: Dispatched when your new scene is about to enter the stage. You can initialize your variables here.
• enterEnd: Dispatched after the transition of new scene has ended. Mostly, you add listeners and start your logic here.
• exitBegin: Dispatched when your current scene is about to leave the stage. You can remove listeners and stop timers here.
• exitEnd: Dispatched after your current scene has leaved the stage.
Cheers
evs
Thanks for the reply. I actually put the code under enterEnd handler and it worked. But the thing is that the init function is called at each scene change (that's how you can give a different argument to the init function at each call). I put a print("...") and it works. The eventlisteners are added inside init, anyway
Thanks.