|
-
Senior Member
[Problem] speed increasing on game restart
I have a game with a 'start' frame, a'play' frame, a 'dead' frame and a 'win' frame. You start by going from the 'start' frame to the 'play' frame and the speed is fine. When you die or win I have a button that takes you back to the 'play' frame but each time you do this the speed of all the objests increases.
Anyone got a clue why this happens or how to fix it?
Last edited by mandissected; 04-10-2005 at 10:50 AM.
-
Senior Member
You have to initialize all your vars before starting over. Inside a functio have something like "speed=0;" or something.
-
smile for the camera!
if you're using setInterval() you have to clear it before setting it again. to clear it, set it like var = setInterval(function, int)
and then clear it with clearInterval(var)
My site
The Current Project is RoboRace.
Screens Public Beta Coming Soon!
-
Senior Member
thanks jesserules, that clearInterval() worked a treat when I've got one movieclip, trouble is when I have several instances of the same movieclip (like enemys), I'm having big trouble. Got any help for that problem? here's the code im trying -
code: var = rock1Move;
var = rock2Move;
function move(){
.......
sp = "(rock1 or rock2)" + Move;
sp = setInterval....
}
function endGame(){
.......
for (i = _root.rocksArray.length-1; i >= 0; i--) {
.......
rockRec = (_root.rocksArray[i]) + "Move";
clear interval(rockRec);
.......
}
.......
}
}
Last edited by mandissected; 04-10-2005 at 10:49 AM.
-
Senior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|