Game Development Reference
In-Depth Information
9.
At the end, we update the coordinates of each touch point:
if ( E == MotionEvent.ACTION_MOVE )
{
for ( int i = 0; i != cnt; i++ )
SendMotion(
event.getPointerId(i),
(int)event.getX(i),
(int)event.getY(i),
true, MOTION_MOVE );
}
}
10. When everything is done, we inform our native gesture decoder about the end of the
events sequence:
SendMotion( MOTION_END, 0, 0, false, MOTION_MOVE );
return E <= MotionEvent.ACTION_MOVE;
}
11. The native
SendMotion()
function accepts the touch point
ID
, the coordinates in
screen pixels, a motion lag, and a
boolean
parameter indicating whether the touch
point is active:
public native static void SendMotion( int PointerID, int x, int y,
boolean Pressed, int Flag );
How it works...
The Android OS sends the notiications about touch points to our application, and the
onTouchEvent()
function transforms the collection of touch events which resides
within a
MotionEvent
object into a sequence of JNI
SendMotion()
calls.
See also
F
Handling multi-touch events on Windows
F
Recognizing gestures