Use a kinetic scroll animation in response to a flick gesture to move an object in a given direction, at a given speed, and with a given frictional coefficient. The movement follows a linear trajectory and is based on decreasing speed at a fixed frame rate. The FrameAnimatorListener.animate method is called at regular intervals with the updated position.
To trigger a kinetic scroll animation, use the FrameAnimator.kineticScroll method:
FrameAnimator.kineticScroll(int startSpeed, int direction, int friction, float angle);
The method takes the following parameters:
startSpeed specifies the initial speed of movement in pixels per second, before any deceleration is applied. Use the flick speed value from the flick event:
int startSpeed = gestureEvent.getFlickSpeed();
direction specifies the direction of movement. The possible values are:
FrameAnimator.FRAME_ANIMATOR_FREE_ANGLE allows kinetic scrolling in any direction.
FrameAnimator.FRAME_ANIMATOR_HORIZONTAL allows kinetic scrolling along the horizontal axis.
FrameAnimator.FRAME_ANIMATOR_VERTICAL allows kinetic scrolling along the vertical axis.
friction specifies the amount of friction applied to the movement. The possible values are:
FrameAnimator.FRAME_ANIMATOR_FRICTION_LOW applies slow deceleration.
FrameAnimator.FRAME_ANIMATOR_FRICTION_MEDIUM applies medium deceleration.
FrameAnimator.FRAME_ANIMATOR_FRICTION_HIGH applies fast deceleration.
This parameter allows the MIDlet to vary the rate of deceleration of the animation. A lower friction value causes the animation to slow down gradually and cover more distance. A higher friction value causes the animation to slow down quicker and cover less distance.
angle specifies the direction of the flick gesture in radians. Use the flick direction value from the flick event:
float angle = gestureEvent.getFlickDirection();