View Full Version : reload time
Moopers
July 4th, 2004, 11:59 AM
ok, i made a game with a guy and a gun. you can fire your gun continuously without stopping. i'm just wondering(cause firing continuously is cheap), if anyone knows how to make it so that your gun has a reload time (i.e. 1 sec)?
Elbudster
July 4th, 2004, 12:57 PM
Well theres probably a bunch of ways to do this. This is probably not the best way to do it but make a seperate sub animation under the character guy and label it reload. Then...
//under main guy for reload script
if (Key.isDown(Key.RELOAD) && !reloading) {
reloading = true;
this.gotoAndStop("reload");
}
//then go into the reload label animation. say if you have 15 fps make a keyframe on frame 15 and then add something like:
_parent.reloading = false;
_parent.bullets = whateverthemaxamountis;
You could do something like that, it's probably not the best way to go about doing it though.
Moopers
July 4th, 2004, 03:50 PM
umm thats not exactly what i want, i want it so that(say spacebar is to fire) if you hold space, your bullet(in this case mine is a laser) will fire once a second or so.
Elbudster
July 5th, 2004, 01:40 AM
in that try something like this...
onClipEvent (load) {
fire = false;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) && !fire) {
fire = true;
this.gotoAndStop("firing");
}
}
//Then like 15 frames out on a sub firing animation add something like...
_parent.fire = false;
tommythewolfboy
July 5th, 2004, 04:18 AM
Or you can use setInterval, and only allow a new laser to be fired once the interval has passed ...
Moopers
July 5th, 2004, 09:16 PM
yes tommy, that's what i wanted, just didn't know what the command was
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.