Skip to content

Instantly share code, notes, and snippets.

@piotr-j
Created May 31, 2018 16:16
Show Gist options
  • Select an option

  • Save piotr-j/44918c0d53cf5cf7364efb4d54bc324d to your computer and use it in GitHub Desktop.

Select an option

Save piotr-j/44918c0d53cf5cf7364efb4d54bc324d to your computer and use it in GitHub Desktop.
graphics.getView().setOnTouchListener(new View.OnTouchListener() {
@Override public boolean onTouch (View view, MotionEvent event) {
final int action = event.getAction() & MotionEvent.ACTION_MASK;
int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
switch (action) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: {
Gdx.app.log("DOWN", pointerIndex + " -> " + event.getPressure(pointerIndex));
} break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP: {
Gdx.app.log("UP", pointerIndex + " -> " + event.getPressure(pointerIndex));
} break;
case MotionEvent.ACTION_MOVE: {
for (int i = 0, n = event.getPointerCount(); i < n; i++) {
Gdx.app.log("MOVE", i + " -> " + event.getPressure(i));
}
} break;
}
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment