Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Look at yusing the Timer class. If you need help seeing how to use it, search Google for a tutorial using terms like "AS3 Timer tutorial"
Each time you fire you need to set a disabler for shooting again and start a timer that resets that disabler after the timeout period passes.
Copy link to clipboard
Copied
Thanks for another quick reply, Ned.
I've looked into google, but the examples and problems other seem to have doesent help me or educate me about that way to use the Timer class.
Is it possible that you could mash down the code, or if you could share any good resource which explains the timer class well that you know of?
Thank you, again.
Copy link to clipboard
Copied
I just did the Google search I suggested you do and found plenty of tutorials made to teach you how to use the Timer class. If none of them are able to help you, it is doubtful anyone here will be able to either, short of doing the programming for you. If you wait around you might find someone who is willing to.
Copy link to clipboard
Copied
Thanks again. After a couple of hours i managed to solve it in another way. I misunderstood AS's boundaries, once i read up on it i found a much better solution.
Thanks again for the willing to help to both you and Andrei1.
- Scott.
Copy link to clipboard
Copied
What is the correlation between frames and shooting behavior? What is the significance of frame 12?
Also, it is not clear how you manage acts of shooting. I mean, how do you invoke it and how you disable it?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now