Game Development Reference
In-Depth Information
17. The last routine calculates the previous element index:
inline size_t AdjustIndex( size_t i ) const
{
return (size_t)ModInt( (int)FHead - (int)i - 1,
(int)FBuffer.size() );
}
};
18. To decode a gesture, we carefully handle each of the touch events. At the beginning
we reset the touch point collection, and at the end of the touch we check for gesture
completion:
void GestureHandler_SendMotion( int ContactID, eMotionFlag
Flag,LVector2 Pos, bool Pressed )
{
if ( ContactID == MOTION_START )
{
FMotionDataValid = false;
FMotionData.Clear();
return;
}
if ( ContactID == MOTION_END )
{
FMotionDataValid = true;
UpdateGesture();
g_Responder->Event_UpdateGesture( FMotionData );
if ( sMotionData* P = FPrevMotionData.prev(0) )
{
if ( P->GetNumTouchPoints() !=
FMotionData.GetNumTouchPoints() )
FPrevMotionData.push_back( FMotionData );
}
else
{
FPrevMotionData.push_back( FMotionData );
}
return;
}
19. If we are still moving, then modify the information about the current point:
if ( Pressed )
FMotionData.AddTouchPoint( sTouchPoint( ContactID, Pos,
MOTION_DOWN, Env_GetSeconds() ) );
 
Search WWH ::




Custom Search