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 › Arrow Key Controls are JUMPY!
Page Index Toggle Pages: 1
Arrow Key Controls are JUMPY! (Read 256 times)
Arrow Key Controls are JUMPY!
Mar 3rd, 2009, 4:39am
 
I'm using arrow key controls and they are very jumpy because the operating system only recognizes the key as being pressed continually after a few seconds, so I cannot get smooth movement on the screen via the arrow keys.  Is there a special command to achieve this?  I remember from AS2 it was something like if( key.isDown(key.UP)){ etc...

I'd really appreciate the help!

Here is a snippet of code that I have so far:

void keyPressed(){
 if(key == CODED){
   if(keyCode == RIGHT){
     //move sprite to the right, or something of the sort
   }
 }
}

Thanks for reading,

-T
Re: Arrow Key Controls are JUMPY!
Reply #1 - Mar 3rd, 2009, 8:50am
 

boolen _right = false;
void keyPressed(){
 if(key == CODED){
   if(keyCode == RIGHT){
     _right = true;
   }
 }
}
void keyReleased(){
 if(key == CODED){
   if(keyCode == RIGHT){
     _right = false;
   }
 }
}

void draw()
{
if(_right){
//move sprite to the right, or something of the sort
}
}
Page Index Toggle Pages: 1