Simulation runs double speed the second time

Hi!

My Box2dWeb game development has halted because of a weird problem: When the player restarts the level, everything happens two times faster than normal. It's as if Box2d is running super fast.
The problem only occurs when the simulation is ran a second time. The first play runs on normal speed.

Why could this be?
Sounds like you are just not stopping the original animation timer and making a new one, so you have two running.
Thanks, you were right and I managed to solve the problem with your help.

I case it helps someone else, the details of my problem were that I was using

Code: Select all

stage.addEventListener(Event.ENTER_FRAME, update);

to attach an eventlistener in the beginning of each level. These naturally started "piling up" when the level was restarted. So the solution was to simply:

Code: Select all

stage.removeEventListener(Event.ENTER_FRAME, update);
after each level was finished!

Original thread: https://box2d.org/forum/viewtopic.php?t=9499