Hello 2All,
I have a problem in handling my ball using D-Pad control.
Here is my code of handling a ball.
public static final int DIRECTION_RIGHT = 0, DIRECTION_UP = 0,
DIRECTION_DOWN = 0, DIRECTION_LEFT = 0;
private int direction = 0;
protected volatile boolean running = true;
public boolean onKeyDown(int KeyCode, KeyEvent event){
if(KeyCode==KeyEvent.KEYCODE_DPAD_CENTER){
if(running == true){
if(KeyCode == KeyEvent.KEYCODE_DPAD_RIGHT){
setDirection(DIRECTION_RIGHT);
}
else if(KeyCode == KeyEvent.KEYCODE_DPAD_DOWN){
setDirection(DIRECTION_DOWN);
}
else if(KeyCode == KeyEvent.KEYCODE_DPAD_LEFT){
setDirection(DIRECTION_LEFT);
}
}
}
else {
running = false;
}
return true;
}
public void setDirection(int direction) {
this.direction = direction;
}
public int getDirection() {
return direction;
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en