Does anyone know how to limit the usage of a weapon in a basic shooting game??
What do you mean? how much ammo the user can use, or how often the user can fire?
how much ammo the user can use. I have special weapons and i want them to be limited to three uses
every time the gun is fired, add 1 to a variable.
everytime the variable changes, do a logical test to see if the variable is equal to 3, and if it is, then do whatever you want - disable the gun or whatever.
could you give me an example of how i would incorporate that into my code this is the code i have on the weapon i want to limit:
onClipEvent (load) {
this._x = _root.spaceship._x;
this._y = _root.spaceship._y;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SHIFT)){
_root.bomb._visible=true;
this.gotoAndPlay(2);
}
}
onClipEvent (enterFrame) {
for (i=1; i<=_root.numEnemy; i++) {
if (this.hitTest(_root[“enemy”+i])) {
_root.score += 25;
_root[“enemy”+i].gotoAndStop(7);
}
}
}
onClipEvent (enterFrame) {
for (k=1; k<=_root.numelaser; k++) {
if (this.hitTest(_root[“elaser”])){
_root[“elaser”+k].gotoAndStop(3);
}
}
}
could you upload the fla so i can see the code in action and see what each bit does. it’d be much easier
thanks.
I don’t know what the deal is but it’s not letting me upload my file.
possible the file is too large. you can email me it if you want.
email it to: paul_scott_1@hotmail.com
the file is too big for hotmail also, I don’t know what else to do.
ok, i figured out how to limit my weapons, but i used a dynamic text box and 1 gets subtracted from three when i use the special weapon. Problem: it doesn’t stop subtracting when it hits 0 and the counter subtracts too fast. How can i slow down the counter and make it stop at 0???
to test when it is at 0, simple do an if test.
target is the name of the dynamic text box:
if (target.text == "0") {
//do actions once weapon limit has reached.
}
as for slowing down the speed it is counting down to the limit at - what method are you using to countdown? what triggers the countdown? can you upload the file?
hope this wee bitty helps you
oh, that’s right, you said it’s too big. maybe you can upload it to a website?
if you’re on msn messenger, you can add me on paul@kerb.ws and send me the file using it.
Ok, this is the code in my special weapon as of now. Hope this is enough cause I don’t actually have access to Messenger at my High School.
onClipEvent (load) {
this._x = _root.spaceship._x;
this._y = _root.spaceship._y;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE)){
_root.bomb._visible=true;
this.gotoAndPlay(2);
_root.ammo-=1;
}
}
onClipEvent (enterFrame) {
for (i=1; i<=_root.numEnemy; i++) {
if (this.hitTest(_root[“enemy”+i])) {
_root.score += 25;
_root[“enemy”+i].gotoAndPlay(2);
}
}
}
onClipEvent (enterFrame) {
if (_root.ammo == 0) {
_root.bomb.gotoAndStop(2);
}
}
onClipEvent (enterFrame) {
for (k=1; k<=_root.numelaser; k++) {
if (this.hitTest(_root[“elaser”])){
_root[“elaser”+k].gotoAndStop(3);
}
}
}
hm… it’s pretty hard to tell when only seeing the code.
where do each of the pieces of code go?
The code i’ve given is on the weapon i’m trying to limit