PDA

View Full Version : [AS2] Key Down Question.


ajk62089
02-28-2009, 07:58 PM
Hello. Im looking to add new weapons to my games. Im not sure how to make it so that it replaces the current bullet movieclip so im making it an ammo type. I would like to make it so that everytime you hit 1,2,3,etc, that it will shoot based on the number you pushed. I noticed that it didnt include any numbers or letters with keydown so i was wondering what the script would be.

if (Key.isDown(Key.(I want this to be 1)) {
i++;

if (timer>=5) {
_root.attachMovie("Bullet1","Bullet1"+i,_root.getNextHighestDepth());
_root["Bullet1"+i]._x = Ship._x+3;
_root["Bullet1"+i]._y = Ship._y;
timer = 0;// Restarts the timer at 0.
}

}

bluemagica
03-01-2009, 04:34 AM
if(key.isDown(32))
You specify the key code for the key....you can find the codes here http://www.asciitable.com/

PS: 32 is space



oh and learn to use arrays properly then you will be able to switch weapons....if you get stuck, ask here!

kkbbcute
03-01-2009, 12:12 PM
Check this out.

http://board.flashkit.com/board/showthread.php?threadid=590288

ajk62089
03-01-2009, 06:56 PM
Thanks a bunch. I already got it so u can use multiple weapons but i couldnt figure out how to use anything other than enter, shift, alt, etc. I tried using the number corresponding to the key like i used to in visual basic but i set it up wrong. Thanks again =).