I am developing an android game. in this i have two moving images on the screen, am able to drag this images, but my further requirement is to pause the image when i touch the image. am not finding any event to pause the image , and than restart moving at the same position where image have been paused.
Can any body tell me the solution. Thanks.
am using onTouch to drag and move the image.
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Parcelable state=null;
// delegating event handling to the droid
droid1.handleActionDown((int)event.getX(), (int)event.getY());
droid2.handleActionDown((int)event.getX(), (int)event.getY());
// check if in the lower part of the screen we exit
if (event.getY() > getHeight() - 50) {
thread.setRunning(false);
((Activity)getContext()).finish();
} else {
Log.d(TAG, "Coords: x=" + event.getX() + ",y=" + event.getY());
}
} if (event.getAction() == MotionEvent.ACTION_MOVE) {
// the gestures
if (droid1.isTouched()) {
// the droid was picked up and is being dragged
droid1.setX((int)event.getX());
droid1.setY((int)event.getY());
}
if (droid2.isTouched()) {
// the droid was picked up and is being dragged
droid2.setX((int)event.getX());
droid2.setY((int)event.getY());
}
} if (event.getAction() == MotionEvent.ACTION_UP ) {
// touch was released
if (droid1.isTouched()) {
droid1.setTouched(false);
}
if (droid2.isTouched()) {
droid2.setTouched(false);
}
}
return true;
}