A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Help needed: countdown timer

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    37

    Help needed: countdown timer

    i need help with a countdown timer for my game, i need it so that when time runs out, my player dies (go to another frame).

    i cant seem to find any tutorials that work well. so i have no code

    Info: players instance: "player"
    timer instance: "timer"

    plz i need help with it asap
    thanks

  2. #2
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Hi, here is some code:
    time = 0;//leave at 0
    want_time = 15;//how many seconds you want the timer for
    onEnterFrame = function(){
    time+=1/30;//set 30 to the fps in your movie
    timer.text = Math.ceil(time);//make the textbox called timer show the time
    if(time==wanted_time){
    player.gotoAndStop("die");
    time = want_time
    }
    }
    This should work fine if you past it onto the main timeline.
    Syntax Error

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    37
    Hi, here is some code:
    time = 0;//leave at 0
    want_time = 15;//how many seconds you want the timer for
    onEnterFrame = function(){
    time+=1/30;//set 30 to the fps in your movie
    timer.text = Math.ceil(time);//make the textbox called timer show the time
    if(time==wanted_time){
    player.gotoAndStop("die");
    time = want_time
    }
    }
    This should work fine if you past it onto the main timeline.
    but it doesnt take me to the game over frame.

    i need to know how to send my guy to the gameover frame (frame 3)

  4. #4
    Senior Member
    Join Date
    Dec 2009
    Posts
    109

    Okay

    Change the line:
    player.gotoAndStop("die");

    To say:
    player.gotoAndStop(3);
    Syntax Error

  5. #5
    Member
    Join Date
    Jul 2009
    Posts
    37
    it still doesnt work, it just keeps going

  6. #6
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    Maybe try player.play(); then go into the player MC and put stop(); into the frame you want. Also maybe change if(time==wanted_time){ to if(time>=wanted_time){
    Syntax Error

  7. #7
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    I think the problem is that the variable is declared as "want_time" and in the if statement you write it as "wanted_time".
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

Tags for this Thread

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