-
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
-
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
-
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)
-
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
-
O cool Ty ill put you in special thanks if i ever finish it!
-
Haha great
Good luck with your game, and be sure to post the finish product up in the game section
-
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|