codejunky

Untitled

Mar 15th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public boolean onFling(MotionEvent event1, MotionEvent event2,
  2.             float velocityX, float velocityY) {
  3.  
  4.     int[] location = new int[2];
  5.     int xLoc, yLoc;    
  6.     for(int idx = 0; idx < numBubbles; idx++) {
  7.         View bubble = mFrame.getChildAt(idx);
  8.         bubble.getLocationOnScreen(location);
  9.         xLoc = (int) event1.getX();
  10.         yLoc = (int) event1.getY();
  11.         if (xLoc == location[0] && yLoc == location[1]) {
  12.               ((BubbleView) bubble).deflect(velocityX, velocityY); // Deflect is a method that increases the speed
  13.                                        // and translates the View object
  14.                break;
  15.         }
  16.         return true;       
  17.     }
  18. }
Add Comment
Please, Sign In to add comment