mad1231999

Untitled

Feb 8th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. // Detect swipes
  2. if(e.getAction() == MotionEvent.ACTION_DOWN) {
  3.     startTime = timing.getCurTimeMillis() / 1000;
  4.     startX = touchX;
  5.     startY = touchY;
  6. }  
  7.        
  8. float dx = startX - touchX;
  9. float dy = startY - touchY;
  10.            
  11. if(dx < -15) { // left-swipe
  12.     if(dy > -45 && dy < 45)
  13.         parentGameHost.onSwipe(SIDE.LEFT);
  14. }
  15.        
  16. if(dx > 15) { // right-swipe
  17.     if(dy > -45 && dy < 45)
  18.         parentGameHost.onSwipe(SIDE.RIGHT);
  19. }
  20.        
  21. if(dy > -15) { // up-swipe
  22.      if(dx > -45 && dx < 45)
  23.          parentGameHost.onSwipe(SIDE.UP);
  24. }
  25.        
  26. if(dy < 15) { // down-swipe
  27.     if(dx > -45 && dx < 45)
  28.         parentGameHost.onSwipe(SIDE.DOWN);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment