Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Detect swipes
- if(e.getAction() == MotionEvent.ACTION_DOWN) {
- startTime = timing.getCurTimeMillis() / 1000;
- startX = touchX;
- startY = touchY;
- }
- float dx = startX - touchX;
- float dy = startY - touchY;
- if(dx < -15) { // left-swipe
- if(dy > -45 && dy < 45)
- parentGameHost.onSwipe(SIDE.LEFT);
- }
- if(dx > 15) { // right-swipe
- if(dy > -45 && dy < 45)
- parentGameHost.onSwipe(SIDE.RIGHT);
- }
- if(dy > -15) { // up-swipe
- if(dx > -45 && dx < 45)
- parentGameHost.onSwipe(SIDE.UP);
- }
- if(dy < 15) { // down-swipe
- if(dx > -45 && dx < 45)
- parentGameHost.onSwipe(SIDE.DOWN);
- }
Advertisement
Add Comment
Please, Sign In to add comment