Reputation: 117
I'm having a setInterval AS3 problem.Let me explain: I'm making a game with a timer, lets for example give its instance, timer1.every 500 milliseconds timer1 moves to left 25 times (timer1.x-=25) and when timer1 hitTests finish1 (if(timer1.hitTestObject(finish1))) it goes to the you lose scene.and you have to replay the level.When I hit replay and enter the scene the speed increases in the setInterval by double and if I lose again, triple and so on.How do fix this? It's very important that I have it fixed soon.thanks
Upvotes: 0
Views: 373
Reputation: 41981
Sounds like multiple instances of timer1
are continuing to run.
1 instance of timer1
runs at original speed.
2 instances of timer1
runs at double speed.
etc.
Ensure that the original timer1
is stopped, deleted or killed off before changing scene.
You may want to reference the function clearInterval
.
Upvotes: 1