本文整理汇总了C#中FingerGestures类的典型用法代码示例。如果您正苦于以下问题:C# FingerGestures类的具体用法?C# FingerGestures怎么用?C# FingerGestures使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FingerGestures类属于命名空间,在下文中一共展示了FingerGestures类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSwipeDirectionVector
public static Vector3 GetSwipeDirectionVector( FingerGestures.SwipeDirection direction )
{
switch( direction )
{
case FingerGestures.SwipeDirection.Up:
return Vector3.up;
case FingerGestures.SwipeDirection.UpperRightDiagonal:
return 0.5f * ( Vector3.up + Vector3.right );
case FingerGestures.SwipeDirection.Right:
return Vector3.right;
case FingerGestures.SwipeDirection.LowerRightDiagonal:
return 0.5f * ( Vector3.down + Vector3.right );
case FingerGestures.SwipeDirection.Down:
return Vector3.down;
case FingerGestures.SwipeDirection.LowerLeftDiagonal:
return 0.5f * ( Vector3.down + Vector3.left );
case FingerGestures.SwipeDirection.Left:
return Vector3.left;
case FingerGestures.SwipeDirection.UpperLeftDiagonal:
return 0.5f * ( Vector3.up + Vector3.left );
}
Debug.LogError( "Unhandled swipe direction: " + direction );
return Vector3.zero;
}
示例2: CanBegin
public override bool CanBegin(Gesture gesture, FingerGestures.IFingerList touches)
{
//Debug.Log(
// UnityUtils.WithTimestamp("Check if tap for " + this.AnimationName + " can begin: " + gesture + ", touches: " + touches.Count), this);
if (this.animation == null || !this.animation.IsPlaying(this.AnimationName))
{
return false;
}
// Just allow tap when touch just began.
if (touches[0].Phase != FingerGestures.FingerPhase.Begin)
{
return false;
}
// Check if tap started after threshold.
AnimationState animationState = this.animation[this.AnimationName];
if (animationState.time < this.Threshold)
{
return false;
}
return true;
}
示例3: FingerGestures_OnFingerSwipe
// spin the yellow cube when swipping it
void FingerGestures_OnFingerSwipe( int fingerIndex, Vector2 startPos, FingerGestures.SwipeDirection direction, float velocity )
{
if(direction== FingerGestures.SwipeDirection.Up)
{
GameManager.instance.CurrentBlock.RotateBlock();
}
}
示例4: OnActive
protected override GestureState OnActive( FingerGestures.IFingerList touches )
{
float motion = Input.GetAxis( axis );
if( Mathf.Abs( motion ) < 0.001f )
{
if( resetTime <= Time.time )
{
RaiseOnPinchEnd();
return GestureState.Recognized;
}
return GestureState.InProgress;
}
else
{
resetTime = Time.time + 0.1f;
}
Position[0] = Position[1] = Input.mousePosition;
delta = DeltaScale * motion;
RaiseOnPinchMove();
return GestureState.InProgress;
}
示例5: IsValidDirection
/// <summary>
/// Return true if the input direction is supported
/// </summary>
public bool IsValidDirection( FingerGestures.SwipeDirection dir )
{
if( dir == FingerGestures.SwipeDirection.None )
return false;
return ( ( ValidDirections & dir ) == dir );
}
示例6: 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;
}
示例7: 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;
}
示例8: SignedAngularGap
// return signed angle in degrees between current finger position and ref positions
static float SignedAngularGap( FingerGestures.Finger finger0, FingerGestures.Finger finger1, Vector2 refPos0, Vector2 refPos1 )
{
Vector2 curDir = ( finger0.Position - finger1.Position ).normalized;
Vector2 refDir = ( refPos0 - refPos1 ).normalized;
// check if we went past the minimum rotation amount treshold
return Mathf.Rad2Deg * FingerGestures.SignedAngle( refDir, curDir );
}
示例9: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
lastTapTime = Time.time;
//Debuger.Log( this + " OnBegin @ " + StartPosition );
}
示例10: FingerGestures_OnFingerSwipe
void FingerGestures_OnFingerSwipe( int fingerIndex, Vector2 startPos, FingerGestures.SwipeDirection direction, float velocity )
{
GameObject selection = PickObject( startPos );
if( selection == swipeObject )
{
rootObject.GetComponent<Button>().Swiped(direction.ToString());
}
}
示例11: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
Position = touches.GetAveragePosition();
StartPosition = Position;
MoveDelta = Vector2.zero;
lastPos = Position;
RaiseOnDragBegin();
}
示例12: CanBegin
protected override bool CanBegin( FingerGestures.IFingerList touches )
{
if( !base.CanBegin( touches ) )
return false;
if( touches.GetAverageDistanceFromStart() < MoveTolerance )
return false;
return true;
}
示例13: CanBegin
protected override bool CanBegin( FingerGestures.IFingerList touches )
{
if( !CheckCanBeginDelegate( touches ) )
return false;
float motion = Input.GetAxis( axis );
if( Mathf.Abs( motion ) < 0.0001f )
return false;
return true;
}
示例14: GetMessageForSwipeDirection
Message GetMessageForSwipeDirection( FingerGestures.SwipeDirection direction )
{
if( direction == FingerGestures.SwipeDirection.Left )
return swipeLeftMessage;
if( direction == FingerGestures.SwipeDirection.Right )
return swipeRightMessage;
if( direction == FingerGestures.SwipeDirection.Up )
return swipeUpMessage;
return swipeDownMessage;
}
示例15: OnBegin
protected override void OnBegin( FingerGestures.IFingerList touches )
{
StartPosition[0] = StartPosition[1] = Input.mousePosition;
Position[0] = Position[1] = Input.mousePosition;
delta = 0;
RaiseOnPinchBegin();
delta = DeltaScale * Input.GetAxis( axis );
resetTime = Time.time + 0.1f;
RaiseOnPinchMove();
}