0

I have this code for my MotionEvents in Android:

@Override
public boolean onTouchEvent(MotionEvent event){

    int action = event.getActionMasked();

    switch (action){
        case MotionEvent.ACTION_UP:
            mGameview.moveUp(30);
            break;
        case MotionEvent.ACTION_DOWN:
            mGameview.moveDown(30);
            break;
    }

    return true;
}

However, instead of these things only triggering when I drag my finger up/down, they both happen simultaneously no matter what I do in the app, for example when I tap, drag left and right.

Rolf ツ
  • 8,611
  • 6
  • 47
  • 72
moxide
  • 65
  • 1
  • 6

1 Answers1

0

Try to get action by:

int action = event.getAction() & MotionEvent.ACTION_MASK;
kenzo
  • 211
  • 1
  • 9
  • sorry it took so late for me to get around doing this, but it still triggers regardless with this addition. do you have any other suggestions? – moxide Dec 31 '16 at 07:58
  • maybe your action form gameview triggers touches? – kenzo Jan 01 '17 at 11:03