So I have a touch event and it handles ACTION_DOWN
and ACTION_UP
one by one. For example if I click on the left half of the screen ACTION_DOWN
works but not ACTION_UP
and same for the right side of the screen. i want to handle both of them simultaneously. If I click on left side and right side at the same time both the event should perform. Can anyone please help me on this.
My code is
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
//if user press the screen
if (event.getX() < screenX / 2f) {
flight.isGoingUp = true;
}
break;
case MotionEvent.ACTION_UP:
flight.isGoingUp = false;
if (event.getX() > screenX / 2f) {
flight.toShoot++;
}
break;
}
return true;
}
Edit 1
The screen is split into two half. The left side of the screen is used for flight.isGoingUp = true;
and when we release the left side or tap the right helg of the screen flight.isGoingUp = false;
and if (event.getX() > screenX / 2f) { flight.toShoot++; }
I want ot do such a code that both of them are handled at the same time.