ard0x
02-18-2004, 10:31 PM
First of all I'm new to the forum, so hi everyone. I'm just delving into my very first actionscript game.
Anyway, I am not sure if this belongs in 'simple stuff', but I'm hoping that it does have a simple solution that I am just not seeing.
I am programming a ship for a game:
- When you press up, a power meter increases by one unit. When you press down, it reduces the power meter by one unit. (I have an LED graphic interface, so I want the levels to rise incrementally on every keystroke.)
- When you press spacebar, it releases the accumlated power, and fires the ship.
I have an algorithm all planned out on how to do this, except for the user input. If it reads Key.isDOWN on every frame, the levels rise WAY too fast, and if I rise by a number less than 1, say 0.3, and then update the display whenever it hits an integer, I fear the controls will feel too sloppy.
Is there a way to:
1. send a *single* signal upon keypress? If my variable "shippower" is suppose to increase by 1 every keystroke, how do I prevent it from adding 1 every single frame that the key is pressed on?
instead of Key.isDown(Key.UP) I guess I am looking for a Key.hasbeenpressed(Key.UP) :)
2. Or better yet, can I somehow use the way a typing keystroke works? (on press, one letter is typed. If you hold it down, there is a delay, and then it repeats at a set interval.)
Thanks in advance.
Anyway, I am not sure if this belongs in 'simple stuff', but I'm hoping that it does have a simple solution that I am just not seeing.
I am programming a ship for a game:
- When you press up, a power meter increases by one unit. When you press down, it reduces the power meter by one unit. (I have an LED graphic interface, so I want the levels to rise incrementally on every keystroke.)
- When you press spacebar, it releases the accumlated power, and fires the ship.
I have an algorithm all planned out on how to do this, except for the user input. If it reads Key.isDOWN on every frame, the levels rise WAY too fast, and if I rise by a number less than 1, say 0.3, and then update the display whenever it hits an integer, I fear the controls will feel too sloppy.
Is there a way to:
1. send a *single* signal upon keypress? If my variable "shippower" is suppose to increase by 1 every keystroke, how do I prevent it from adding 1 every single frame that the key is pressed on?
instead of Key.isDown(Key.UP) I guess I am looking for a Key.hasbeenpressed(Key.UP) :)
2. Or better yet, can I somehow use the way a typing keystroke works? (on press, one letter is typed. If you hold it down, there is a delay, and then it repeats at a set interval.)
Thanks in advance.