View Full Version : On Key Down instead of On Key Up
alphaleader
04-02-2008, 06:28 PM
I have to make a game for my programming class, but one of the actions needs to start an animation as soon as the key for the character movement is pressed. That works fine, just as long as im okay with the action activating when the key is released, but would prefer on key down.
Any ideas.
Lprsti99
04-03-2008, 12:33 PM
Create another "When a key is typed" event. Right click and change the event into a "While a key is pressed" event, which is a BDE event. Set the key to the movement key. In the Begin section, put the animation you want to run, and I believe it will do what you want. Granted, this will only work if you have one movement key, but, if all else fails, create an event group and make the same event for each key.
Also, a suggestion, unless you want this animation to run every time a key is pressed, create a boolean world variable, called something like animHasNotRun. Modify the animation's method, putting the entire thing in the if part of an if/else statement. Set the condition to be "If [animHasNotRun]", and have the very first line of code in the if section set the variable to false. This way, it will only run the first time the key is pressed.
alphaleader
04-03-2008, 05:49 PM
That does make more sense, and if it works they way it sounds like it would, it will work much better in this application.
Sorry for the dumb question, I just started with alice a month ago.
Lprsti99
04-05-2008, 10:35 PM
Not a dumb question at all, it's actually a very good one. Don't sell yourself short.
DrJim
04-06-2008, 10:42 AM
The only truely dumb question is the one you don't ask.