Game Development Reference
In-Depth Information
size_t GetNumTouchPoints() const { return
FTouchPoints.size(); }
const sTouchPoint& GetTouchPoint( size_t Idx ) const {
return FTouchPoints[Idx]; }
vec2 GetTouchPointPos(size_t i) const { return
FTouchPoints[i].FPoint; }
int GetTouchPointID(size_t i) const { return
FTouchPoints[i].FID; }
void AddTouchPoint( const sTouchPoint& TouchPoint )
{
for ( size_t i = 0; i != FTouchPoints.size(); i++ )
if ( FTouchPoints[i].FID == TouchPoint.FID )
{
FTouchPoints[i] = TouchPoint;
return;
}
FTouchPoints.push_back( TouchPoint );
}
private:
std::vector<sTouchPoint> FTouchPoints;
};
9.
A gesture is described by the current state of its touch points and a ring buffer of
previous touch point states. To detect a gesture, we create an ad-hoc state machine.
Two Boolean variables indicate if we really have the gesture and if the gesture is
progressing. Validity lags are also stored for each kind of gesture:
sMotionData FMotionData;
RingBuffer<sMotionData> FPrevMotionData(5);
bool FMotionDataValid = false;
bool FMoving = false;
bool FFlingWasValid = false;
bool FPinchZoomValid = false;
bool FPinchZoomWasValid = false;
10. Single-inger gestures, like ling, drag, or tap, are described by the current and initial
touch points. The pinch-zoom is a two-inger gesture whose state is determined by
two initial points and two current points. Centers are calculated as the average of the
initial and current point coordinates:
sTouchPoint FInitialPoint( 0, LVector2(), MOTION_MOVE, 0.0 );
sTouchPoint FCurrentPoint( 0, LVector2(), MOTION_MOVE, 0.0 );
 
Search WWH ::




Custom Search