How do i turn this code into multi touch? What would can I do differently?
in
Android Processing
•
2 months ago
@Override
public boolean dispatchTouchEvent(MotionEvent event){
final int action = event.getActionMasked();
switch(action){
case MotionEvent.ACTION_DOWN:{
float x = event.getX();
float y = event.getY();
if (x >= 50 && x <= 250 && y >= 521 && y <= 721){
my_ship.shoot();
x_angle = atan2(y-620, x-100);
}
else if(x >= 1050 && x < width-50 && y >= 521 && y <= 721) my_ship.push();
break;
//else thrusters = false;
}
case MotionEvent.ACTION_MOVE:{
float xm = event.getX();
float ym = event.getY();
if (game_started == true && xm >= 50 && xm <= 250 && ym >= 521 && ym <= 721){
my_ship.shoot();
x_angle = atan2(ym-620, xm-100);
}else if (xm >= 1050 && xm < width-50 && ym >= 521 && ym <= 721) {
my_ship.push();
}
if (game_started == false && xm > width/2-200 && xm < width/2+200 && ym <= height/2+200 && ym >= 200) game_started = true;
}break;
}
public boolean dispatchTouchEvent(MotionEvent event){
final int action = event.getActionMasked();
switch(action){
case MotionEvent.ACTION_DOWN:{
float x = event.getX();
float y = event.getY();
if (x >= 50 && x <= 250 && y >= 521 && y <= 721){
my_ship.shoot();
x_angle = atan2(y-620, x-100);
}
else if(x >= 1050 && x < width-50 && y >= 521 && y <= 721) my_ship.push();
break;
//else thrusters = false;
}
case MotionEvent.ACTION_MOVE:{
float xm = event.getX();
float ym = event.getY();
if (game_started == true && xm >= 50 && xm <= 250 && ym >= 521 && ym <= 721){
my_ship.shoot();
x_angle = atan2(ym-620, xm-100);
}else if (xm >= 1050 && xm < width-50 && ym >= 521 && ym <= 721) {
my_ship.push();
}
if (game_started == false && xm > width/2-200 && xm < width/2+200 && ym <= height/2+200 && ym >= 200) game_started = true;
}break;
}
1