We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › is there any way to disable a key press
Page Index Toggle Pages: 1
is there any way to disable a key press ? (Read 876 times)
is there any way to disable a key press ?
Apr 20th, 2010, 8:31am
 
im building a game where you shoot asteroids, but i have a problem, when the ship gets hit by an asteroid you can still shoot even though its destroyed so i was wondering if there was anyway to disable the spacebar while the space ship is destroyed ?

Many thanks
Re: is there any way to disable a key press ?
Reply #1 - Apr 20th, 2010, 8:39am
 
Set up a boolean variable.
Set this to false when the ship is destroyed.
Test that the boolean is true when the fire key is pressed.
Re: is there any way to disable a key press ?
Reply #2 - Apr 20th, 2010, 8:44am
 
i currently have a boolean and it half works as it stops the missle going across the screen but when the key is pressed you can see the missle come out the end of the ship and then disapear, also it makes a shooting sound.
Re: is there any way to disable a key press ?
Reply #3 - Apr 20th, 2010, 9:15am
 
You don't disable space bar, you just ignore this event when your program is in a given state.
Page Index Toggle Pages: 1