Game Development Reference
In-Depth Information
sTouchPoint FInitialPoint1, FInitialPoint2;
sTouchPoint FCurrentPoint1, FCurrentPoint2;
float FZoomFactor = 1.0f;
float FInitialDistance = 1.0f;
LVector2 FInitialCenter, FCurrentCenter;
11. To ignore accidental screen touches, we introduce a sensitivity threshold, which is the
smallest percent of the screen space a inger must travel for the ling gesture to be
detected:
float FlingStartSensitivity = 0.2f;
12. The ling gesture is completely ignored if the inger's inal position moves from the
initial position by less than the following value:
float FlingThresholdSensitivity = 0.1f;
13. The RingBuffer data structure is implemented using a simple dynamic array. The
full source code is in the RingBuffer.h ile:
template <typename T> class RingBuffer
{
public:
explicit RingBuffer(size_t Num): FBuffer(Num) { clear(); }
inline void clear() { FCount = FHead = 0; }
inline void push_back( const T& Value )
{
if ( FCount < FBuffer.size() ) FCount++;
FBuffer[ FHead++ ] = Value;
if ( FHead == FBuffer.size() ) FHead = 0;
}
14. The only special method is the accessor to previous states, relative to FHead :
inline T* prev(size_t i)
{ return (i >= FCount) ? NULL: &FBuffer[AdjustIndex(i)]; }
private:
std::vector<T> FBuffer;
15. The current element and the total number of items:
size_t FHead;
size_t FCount;
16. Division remainder with the wrapping around for negative values:
inline int ModInt( int a, int b )
{ int r = a % b; return ( r < 0 ) ? r+b : r; }
 
Search WWH ::




Custom Search