//Motion detector
linear1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View p1, MotionEvent p2){
switch(p2.getAction()) {
case MotionEvent.ACTION_DOWN:
y1 = p2.getY();
x1 = p2.getX();
break;
case MotionEvent.ACTION_UP:
y2 = p2.getY();
x2 = p2.getX();
if (((y1 - y2) < -250)) {
_down();
}
if (((y2 - y1) < -250)) {
_up();
}
if (((x1 - x2) < -250)) {
_right();
}
if (((x2 - x1) < -250)) {
_left();
}
break;
}
return true;
}});
//Create 4 Number Variable
y1, y2, x1, x2
//Create 4 more block
up
down
left
right
Video Help