I'm starting work on a 2D Android game where the player will put their finger on a game piece and do a fling gesture to throw the piece across the gameboard.

I've gone through some Android interpolation animation tutorials and have the fling working, and the game piece (currently the only item on the board) moving almost as intended.

However, I'm utterly flumoxed as to how I would work collision detection into this, as it seems to me that the fling gesture, and the resulting movement of the piece is a complete, uninterruptable action.

Are there any existing Android resources that implement 2D ball physics whilst also allowing things to be moved by flinging? The next move in the game would only be made once all game pieces had come to rest, so it's only the initial action that requires the fling.

Failing that, could someone kindly point out some good resources that might be relevant to my question? My Google hunting has pretty much just liquified my brain.


1 Answer 1


The default Fling and Animations provided by the Android API are there for common animations. Here, you wan't something quite specific so I would suggest using a Fling detection as an input in a Physic simulation engine.

  • \$\begingroup\$ I agree, but how. How do you take speed and direction of a gesture and use it as, you say, an input into a Physics simulation engine (such as Andengine, for example)? \$\endgroup\$
    – JimBadger
    Jul 27, 2011 at 15:20
  • 1
    \$\begingroup\$ If you implement the OnGestureListener the onFling method will provide you with the touch down and touch up position, as well as the velocity, which you can convert in your physic engine unit. \$\endgroup\$
    – XGouchet
    Jul 28, 2011 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .