Game Development Reference
In-Depth Information
5.
Get the coordinates of the primary touch point:
int x = (int)event.getX(), y = (int)event.getY();
int cnt = event.getPointerCount();
6.
Process the touch start:
if ( E == MotionEvent.ACTION_DOWN )
{
for ( int i = 0; i != cnt; i++ )
SendMotion( event.getPointerId(i),
(int)event.getX(i),
(int)event.getY(i),
true, MOTION_DOWN );
}
7.
Process the end of the whole gesture when all the touches are released:
if ( E == MotionEvent.ACTION_UP ||
E == MotionEvent.ACTION_CANCEL )
{
SendMotion( MOTION_END, 0, 0, false, MOTION_UP );
return E <= MotionEvent.ACTION_MOVE;
}
8.
Process secondary touch points:
int maskedEvent = event.getActionMasked();
if ( maskedEvent== MotionEvent.ACTION_POINTER_DOWN )
{
for ( int i = 0; i != cnt; i++ )
SendMotion( event.getPointerId(i),
(int)event.getX(i),
(int)event.getY(i),
true, MOTION_DOWN );
}
if ( maskedEvent == MotionEvent.ACTION_POINTER_UP )
{
for ( int i = 0; i != cnt ; i++ )
SendMotion( event.getPointerId(i),
(int)event.getX(i),
(int)event.getY(i),
i != nPointerID, MOTION_UP );
SendMotion( nPointerID,
(int)event.getX(nPointerID),
(int)event.getY(nPointerID),
false, MOTION_MOVE );
}
 
Search WWH ::




Custom Search