A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: FP Shoot'em'up

  1. #1
    Member
    Join Date
    May 2005
    Posts
    44

    FP Shoot'em'up

    Right i know how to make the normal button in movieclip thing with scores and all but there are a few things i dont know.
    1. Is there an actionscript code for waiting a random time???
    2. Is there a way make a timer???
    3. How do i make it so when the score (variable = score) reaches a certain number then you proceed to another frame???

    Thanks in advance

  2. #2
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey,

    Well start by making the timer. In your first frame on your main timeline, open up the actions panel and put:

    timer = Math.floor(getTimer()/1000);

    That basically sets a variable called timer to start counting the seconds.


    For the random number, I know you can use Math.Random(number);, but Im not sure how to round it since it gives you decimals and stuff ... so someone else is going to have to help you with that.


    Finally, to make it when your score reaches another number and to change frames.
    Make your score into a movieclip and put the code:

    code:
    onClipEvent(load){
    score = 0; // set score
    scoreReach = 100; // what the player has to reach
    }

    onClipEvent(enterFrame){
    if (this.score == this.scoreReach){
    _root.gotoAndStop (4);
    }
    }



    So basically it checks if the score equals scoreReach. If it does, it tells the _root (or the maintimeline in other words) to go to and stop on frame 4

    You will of course change the numbers around to suit your needs, but that should do the trick

  3. #3
    Member
    Join Date
    May 2005
    Posts
    44
    Thanks! 1 thing how can i make the timer stop when the level is over and be diplayed on the next frame??? so it says YOU WIN!! time take : (time here)

  4. #4
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey,

    Well you dont need to stop the time , simply tell your dynamic text box to equal the timer variable in your main timeline

    Ok, so if you go to frame 3 when you win, and frame 3 of the main timeline, simply put the code:

    code:
    myTextBox.text = _root.timer;



    And it will display the time

  5. #5
    Member
    Join Date
    May 2005
    Posts
    44
    O cool Ty ill put you in special thanks if i ever finish it!

  6. #6
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Haha great

    Good luck with your game, and be sure to post the finish product up in the game section

  7. #7
    Member
    Join Date
    May 2005
    Posts
    44
    yeah i will

  8. #8
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey,

    Just a quick note about random numbers , I found out what it was

    Say you had a variable called randomNumber, and you wanted to do what its name suggests, have it hold a random number

    Then the code for that would be:

    code:
    randomNumber = Math.ceil(Math.random()*5);



    The Math.random uses decimals, but by putting the Math.ceil before it, it rounds the number up to the closest WHOLE number

    Anyways, good luck

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