Animation speed doubles every level

Hi,

Sorry for the cross-post from Dev Support, but this baffles me and I’ve tested it quite extensively. EIther I have some sort of recursion bug, but it looks like the events keep getting delivered once I activate them again, either using timers or event listeners. I’ve even tried explicit garbage collection… Anyway here’s the post:

" I have a simple game that basically consists of one level (script) and a number of groups with two images that animate across the screen. At the end of the level I stop the animation (this is visible), reset all the variables and add one item, and start the animation level again which creates the illusion of a next level.

I’ve tried both frame-based animation and time-based animation (Runtime:addEventListener or timer.performWithDelay), but the animation speed doubles every time a new level is started. I have a fixed very slow speed now (for testing), and the only way I think it speeds up if there are more events (so the animation listener gets called more often).

Any clue on why this might happen, or a workaround? Or a way to see if there are no zombie event generators?

To Corona’s credit, it get’s very fast without problem - most people can’t get it fast enough, which is kind of ironic. This is using the newly released SDK (build 703). "

Thanks, Maarten [import]uid: 5822 topic_id: 18927 reply_id: 318927[/import]

I added this to the animation listener and it indeed shows that the removal doesn’t take place:

local newTime = socket.gettime()
local diff = (newTime - lastAnimationTime) * 1000
lastAnimationTime = newTime
print(“animation function called after " … diff … " milliseconds.”)

So a workaround will probably be to do the animation if diff > some threshold. Weird stuff though, no?
[import]uid: 5822 topic_id: 18927 reply_id: 72907[/import]

by animation you mean sprite’s speed or transition time? [import]uid: 16142 topic_id: 18927 reply_id: 72910[/import]

What happens is that the Runtime:removeEventListener is called but not respected. The code posted above showed that there were call being mande more and more at very low times (105 millisec), and for the new iteration every 32-33 milliseconds.

So I just put an if diff > 32 then … around the animation code.

Note that I use a group with two images (much lie the famous fishies example), and transition.to in the animation code, but that all doesn’t seem to matter. Anyway, worked around it… [import]uid: 5822 topic_id: 18927 reply_id: 72914[/import]