本文整理汇总了C#中FingerGestures.GetAveragePosition方法的典型用法代码示例。如果您正苦于以下问题:C# FingerGestures.GetAveragePosition方法的具体用法?C# FingerGestures.GetAveragePosition怎么用?C# FingerGestures.GetAveragePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FingerGestures
的用法示例。
在下文中一共展示了FingerGestures.GetAveragePosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnActive
protected override GestureState OnActive( FingerGestures.IFingerList touches )
{
if( touches.Count != RequiredFingerCount )
{
// all fingers lifted - fire the tap event
if( touches.Count == 0 )
{
RaiseOnTap();
return GestureState.Recognized;
}
// either lifted off some fingers or added some new ones
return GestureState.Failed;
}
// check if the gesture timed out
if( MaxDuration > 0 && ElapsedTime > MaxDuration )
return GestureState.Failed;
// check if finger moved too far from start position
float sqrDist = Vector3.SqrMagnitude( touches.GetAveragePosition() - StartPosition );
if( sqrDist >= MoveTolerance * MoveTolerance )
return GestureState.Failed;
return GestureState.InProgress;
}
示例2: OnActive
protected override GestureState OnActive( FingerGestures.IFingerList touches )
{
if( touches.Count != RequiredFingerCount )
{
// fingers were lifted off
if( touches.Count < RequiredFingerCount )
{
RaiseOnDragEnd();
return GestureState.Recognized;
}
return GestureState.Failed;
}
Position = touches.GetAveragePosition();
MoveDelta = Position - lastPos;
if( MoveDelta.sqrMagnitude > 0 )
{
RaiseOnDragMove();
lastPos = Position;
}
return GestureState.InProgress;
}
示例3: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
lastTapTime = Time.time;
//Debuger.Log( this + " OnBegin @ " + StartPosition );
}
示例4: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
MoveDelta = Vector2.zero;
lastPos = Position;
RaiseOnDragBegin();
}
示例5: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
}
示例6: OnActive
protected override GestureState OnActive( FingerGestures.IFingerList touches )
{
wasDown = down;
down = false;
if( touches.Count == RequiredFingerCount )
{
down = true;
lastDownTime = Time.time;
}
else if( touches.Count == 0 )
{
down = false;
}
else
{
// some fingers were lifted off
if( touches.Count < RequiredFingerCount )
{
// give a bit of buffer time to lift-off the remaining fingers
if( Time.time - lastDownTime > 0.25f )
return GestureState.Failed;
}
else // fingers were added
{
if( !Young( touches ) )
return GestureState.Failed;
}
}
if( HasTimedOut() )
{
// if we requested unlimited taps and landed at least one, consider this a success
if( RequiredTaps == 0 && Taps > 0 )
{
// if we didn't raise a tap event on each tap, at least raise the event once at the end of the tap sequence
if( !RaiseEventOnEachTap )
RaiseOnTap();
return GestureState.Recognized;
}
// else, timed out
return GestureState.Failed;
}
if( down )
{
// check if finger moved too far from start position
float sqrDist = Vector3.SqrMagnitude( touches.GetAveragePosition() - StartPosition );
if( sqrDist >= MoveTolerance * MoveTolerance )
return GestureState.Failed;
}
if( wasDown != down )
{
// fingers were just released
if( !down )
{
++taps;
lastTapTime = Time.time;
// If the requested tap count has been reached, validate the gesture and stop
if( RequiredTaps > 0 && taps >= RequiredTaps )
{
RaiseOnTap();
return GestureState.Recognized;
}
if( RaiseEventOnEachTap )
RaiseOnTap();
}
}
return GestureState.InProgress;
}
示例7: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
direction = FingerGestures.SwipeDirection.None;
}
示例8: OnActive
protected override GestureState OnActive( FingerGestures.IFingerList touches )
{
if( touches.Count != RequiredFingerCount )
{
// fingers were lifted off
if( touches.Count < RequiredFingerCount )
{
if( direction != FingerGestures.SwipeDirection.None )
{
if( OnSwipe != null )
OnSwipe( this );
return GestureState.Recognized;
}
}
return GestureState.Failed;
}
Position = touches.GetAveragePosition();
Move = Position - StartPosition;
float distance = Move.magnitude;
// didnt move far enough
if( distance < MinDistance )
return GestureState.InProgress;
if( ElapsedTime > 0 )
velocity = distance / ElapsedTime;
else
velocity = 0;
// we're going too slow
if( velocity < MinVelocity )
return GestureState.Failed;
FingerGestures.SwipeDirection newDirection = FingerGestures.GetSwipeDirection( Move.normalized, DirectionTolerance );
// we went in a bad direction
if( !IsValidDirection( newDirection ) || ( direction != FingerGestures.SwipeDirection.None && newDirection != direction ) )
return GestureState.Failed;
direction = newDirection;
return GestureState.InProgress;
}
示例9: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
lastTapTime = Time.time;
startTime = Time.time;
}