A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: speed increasing on game restart

  1. #1
    Senior Member mandissected's Avatar
    Join Date
    Jan 2005
    Location
    Berwick - England
    Posts
    338

    [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.

  2. #2
    Senior Member kendude's Avatar
    Join Date
    Sep 2003
    Location
    Hartford, CT USA
    Posts
    877
    You have to initialize all your vars before starting over. Inside a functio have something like "speed=0;" or something.

  3. #3
    smile for the camera! jesserules's Avatar
    Join Date
    Dec 2004
    Location
    a dark place where people have trouble in flash
    Posts
    720
    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!

  4. #4
    Senior Member mandissected's Avatar
    Join Date
    Jan 2005
    Location
    Berwick - England
    Posts
    338
    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.

  5. #5
    Senior Member mandissected's Avatar
    Join Date
    Jan 2005
    Location
    Berwick - England
    Posts
    338
    Any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center