示例#1
0
    /// <summary>
    /// 手势识别
    /// </summary>
    protected override GestureState OnRecognize(DragPressGesture gesture, IFingerList touches)
    {
        if (touches.Count != RequiredFingerCount)
        {
            // fingers were lifted off
            if (touches.Count < RequiredFingerCount)
            {
                return(GestureState.Ended);
            }

            return(GestureState.Failed);
        }

        if (RequiredFingerCount >= 2 &&
            touches.AllMoving() && !touches.MovingInSameDirection(0.35f))
        {
            return(GestureState.Failed);
        }

        gesture.position  = touches.GetAveragePosition();
        gesture.LastDelta = gesture.DeltaMove;
        gesture.DeltaMove = gesture.position - gesture.LastPos;

        if (gesture.DeltaMove.sqrMagnitude > 0 || gesture.LastDelta.sqrMagnitude > 0)
        {
            gesture.LastPos = gesture.position;
        }

        RaiseEvent(gesture);
        return(GestureState.InProgress);
    }
示例#2
0
 /// <summary>
 /// 手势开始
 /// </summary>
 protected override void OnBegin(DragPressGesture gesture, IFingerList touches)
 {
     gesture.position      = touches.GetAveragePosition();
     gesture.startPosition = touches.GetAverageStartPosition();
     gesture.DeltaMove     = gesture.position - gesture.startPosition;
     gesture.LastDelta     = Vector2.zero;
     gesture.LastPos       = gesture.position;
 }
示例#3
0
 protected override void OnBegin(LongPressGesture gesture, IFingerList touches)
 {
     gesture.position      = touches.GetAveragePosition();
     gesture.startPosition = touches.GetAverageStartPosition();
 }