Problem with removeEventListener()/game loop

Hello all,

I am using director.lua to change scenes when options are selected from menu and that is working fine.
But now i try to include some animations for those menus.

in end of menu.lua (which is my main menu) i set up event listener

1
Runtime:addEventListener("enterFrame", menuAnimation)

I don't quite understand what the removeEventListener call isn't doing that you think it should. Are you running an animation that you want to stop when the player touches a button?

Yes, i set up eventlistener to call menuanimation function on start of every frame ( this keep animations running while in main menu) and when user push Play button from main menu, to play actual game, removeEventListener should stop those menuanimation funtion calls, but it don't do it and those menuanimation calls keep going all the time.

the code looks ok. you said don't do what you think it should do but din't say what it does right now.

your code already does what it requires to call menuAnimation on each frame.
Runtime:addEventListener("enterFrame", menuAnimation)

are you getting any error ? whats the problem you are facing ?

Solved this by changing this...

1
2
3
local function menuAnimation()
 
end

Same problem here, thank you so much for figuring it out. I have been working at this bug for ages now with no idea what could be wrong. Took off the word "local" and it magically works properly now!!! Thanks so much!

Move your menuAnimation function above your press play function and it should solve the problem. You shouldn't need to remove the local declaration.

views:1615 update:2011/11/14 9:16:56
corona forums © 2003-2011