-
I`m making a game, and have a timer that counts down the time and move to frame 3 when the time has counted down to zero. That part I figured out.
Two questions;
1.The timer on the game screen has 3 digits after the dot, ex: "3.345 seconds"
Any one know how to make that just one digit or none at all????? ("3.1 seconds", or "3 seconds")
2.The game has 3 frames: frame1 is a instruction screen, frame 2 is the actual game, and frame 3 tells the user how he did it, now; the problem is that when You click the "start" button in frame1 and jump to frame2, the timer has already started to count down, how can I make the timer wait until the user clicks the "start" button in frame1???
The code for the timer(in frame2):
onClipEvent (enterFrame) {
elapsed = getTimer()/1000;
_root.time.time = 60 - elapsed;
if (elapsed>60) {
_root.theEnd = "You made: "+ _root.points + " points!";
tellTarget (_root) {
gotoAndStop (3);
}
}
}
--NuCleuZ--
-
To start your timer when frame 2 is playedy,
Put this code in Frame 2:
starttime = getTimer ()/1000;
and in your clipevent code:
_root.time.time = 60 - (elapsed - starttime);
If you want to round to a whole number change that to:
_root.time.time = 60 - Math.ceil (elapsed - starttime)
If you want to round to 1 decimal place, don't divide the getTimers by 1000, divide them by 100, and then:
_root.time.time = 60 - Math.ceil (elapsed - starttime) / 10
That should work.
em
-
Thanx!! that worked perfectly!!!
--NuCleuZ--
The game:
http://home.world-online.no/~nucleuz...azerunner.html
(just a preview of what`s comming, comments on this one??)