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 & HelpSyntax Questions › Key-responses...
Page Index Toggle Pages: 1
Key-responses... (Read 233 times)
Key-responses...
Mar 29th, 2010, 5:31am
 
In one of my recent sketches (http://processing.tavernmaker.de/JumpMan) I'm using key-control. Now, I've got reports that the keys are sometimes not recognized, and I wonder if this is a bug or sub-ideal programming.
They way I do it is

Each "player" has one "hotkey" (key stored in the according object) and WHILE IT IS PRESSED it is attached to something, whereas while it is not pressed, the links break. The according code I use it (simplified):

Code:

void keyPressed()
{
for (int i=0;i<Players.size();i++)
{
JM = ( JumpMan ) Players.get(i);
if (key==JM.HotKey) JM.free=false;
}
}

void keyReleased()
{
for (int i=0;i<Players.size();i++)
{
JM = ( JumpMan ) Players.get(i);
if (key==JM.HotKey) JM.RemoveSprings();
}
Page Index Toggle Pages: 1