hi my key press codes is below
with this codes i need to keep pressing the left/right/down/up key in order for the image to move. Can anyone teach me how can i just hold the left/right/down/up key and the image will move continuously?Code:public void keyPressed(int keyCode) { // what game action does this key map to? int gameAction = getGameAction(keyCode); if(gameAction == RIGHT) { x += dx; } else if(gameAction == LEFT) { x -= dx; } else if(gameAction == UP) { y -= dy; } else if(gameAction == DOWN) { y += dy; }else if(gameAction== FIRE) { setX=x; setY=y; mustRepaint=false; } repaint(); }

Reply With Quote




