Convert a frame-timer into a MS-timer
Hi guys, im currently working on a shooting-game and something has been bugging my mind for the last hour or so. Im not very skilled with AS3 so please be patient with me.
Ok, so the problem I'm currently having, is that i have a timer which counts frames, which i want to turn into a millisecond timer.
The situation is that it is a timer which is supposed to work as a "break" between every time you can fire a shot.
I have the following code;
Makes the timer:
//how much time before allowed to shoot again
var cTime:int = 0;
//the time it has to reach in order to be allowed to shoot (in frames)
var cLimit:int = 12;
//whether or not the user is allowed to shoot
var shootAllow:Boolean = true;
//checking if cTime has reached the limit yet
if(cTime < cLimit){
cTime ++;
} else {
//if it has, then allow the user to shoot
shootAllow = true;
//and reset cTime
cTime = 0;
}
}
}
---------
So, i was wondering if anyone could "convert" it into so that instead of if having to reach 12 frames, it will allow the player to shoot every 0.5 second (So that it resets and make its able to shoot again after 0,5 seconds).
Any help or feedback is muchly appriciated. Thanks guys!
