Hello,
I have 2 scenes now, a house scene and a school scene. In both scenes it should be possible to enter a world map where you can choose togo to another scene. Everything works fine as long as both scenes are starting for the first time
For example the game starts in the house scene, and then you enter the world map and open the school scene. Works perfectly fine.
But when I am i the school scene and go back to the house scene, a lot of things go wrong. This is because when you open the house scene it will not restart/create the whole scene, but only enter the scene. Now I thought i fixed that by assigning most variables, which should be set to the original position and amount, to assign them all in the enterScene event. Also I put the addEventListeners in the enterScene event, (and nowhere else).But now I get another error.
When I exit the school scene to go back to the house scene. It should remove all event listeners and set a couple of variables to nil
[lua]function scene:exitScene( event )
local group = self.view
Runtime:removeEventListener(“touch”, onTouch )
Runtime:removeEventListener(“enterFrame”, EnterFrame)
for o=1,#characters do
characters[o]:addEventListener( “tap”, onTapNPC )
end
print(“exitScene”)
loader:removeSelf()
loader = nil
player = nil
gf = nil
mom = nil
lhGroup:removeSelf()
lhGroup = nil
physics.stop()
end[/lua]
BUT now when the game has already entered the house scene, and by some print functions I can see it already did this and also should have removed all the listeners in the exitScene event in the school. I get and error from the school scene, because it is still running the enterFrame event from the SCHOOL scene!
I copied all the code from both scenes so both scenes are exactly the same (Apart from the names in some tags and the print functions).
So what really confuses me is that this enterFrame problem doesn’t happen when you go from the house scene to the school scene. But when I go from the school to house scene this problem occurs. Even though the removeEventListener for the enterFrame has been executed [import]uid: 118839 topic_id: 33866 reply_id: 333866[/import]
[import]uid: 118839 topic_id: 33866 reply_id: 134793[/import]