Пример #1
0
 TwistGesture(TwistGestureRecognizer recognizer, CommonTouch touch1, CommonTouch touch2) : base(recognizer)
 {
     fingerId1      = touch1.fingerId;
     fingerId2      = touch2.fingerId;
     startPosition1 = touch1.position;
     startPosition2 = touch2.position;
 }
Пример #2
0
 /// <summary>
 /// Constructs a PinchGesture gesture.
 /// </summary>
 /// <param name="recognizer">The gesture recognizer.</param>
 /// <param name="touch1">The first touch that started this gesture.</param>
 /// <param name="touch2">The second touch that started this gesture.</param>
 public TwistGesture(TwistGestureRecognizer recognizer, Touch touch1, Touch touch2) :
     base(recognizer)
 {
     FingerId1      = touch1.fingerId;
     FingerId2      = touch2.fingerId;
     StartPosition1 = touch1.position;
     StartPosition2 = touch2.position;
 }
Пример #3
0
        /// <summary>
        /// Returns true if this gesture can start.
        /// </summary>
        /// <returns>True if the gesture can start.</returns>
        protected internal override bool CanStart()
        {
            if (GestureTouchesUtility.IsFingerIdRetained(FingerId1) ||
                GestureTouchesUtility.IsFingerIdRetained(FingerId2))
            {
                Cancel();
                return(false);
            }

            Touch touch1, touch2;
            bool  foundTouches = GestureTouchesUtility.TryFindTouch(FingerId1, out touch1);

            foundTouches =
                GestureTouchesUtility.TryFindTouch(FingerId2, out touch2) && foundTouches;

            if (!foundTouches)
            {
                Cancel();
                return(false);
            }

            // Check that both fingers are moving.
            if (touch1.deltaPosition == Vector2.zero || touch2.deltaPosition == Vector2.zero)
            {
                return(false);
            }

            TwistGestureRecognizer twistRecognizer = m_Recognizer as TwistGestureRecognizer;

            float rotation = CalculateDeltaRotation(
                touch1.position, touch2.position, StartPosition1, StartPosition2);

            if (Mathf.Abs(rotation) < twistRecognizer.m_SlopRotation)
            {
                return(false);
            }

            return(true);
        }
Пример #4
0
 /// <summary>
 /// Constructs a PinchGesture gesture.
 /// </summary>
 /// <param name="recognizer">The gesture recognizer.</param>
 /// <param name="touch1">The first touch that started this gesture.</param>
 /// <param name="touch2">The second touch that started this gesture.</param>
 public TwistGesture(TwistGestureRecognizer recognizer, InputSystem.EnhancedTouch.Touch touch1, InputSystem.EnhancedTouch.Touch touch2)
     : this(recognizer, new CommonTouch(touch1), new CommonTouch(touch2))
 {
 }
Пример #5
0
 /// <summary>
 /// Constructs a PinchGesture gesture.
 /// </summary>
 /// <param name="recognizer">The gesture recognizer.</param>
 /// <param name="touch1">The first touch that started this gesture.</param>
 /// <param name="touch2">The second touch that started this gesture.</param>
 public TwistGesture(TwistGestureRecognizer recognizer, Touch touch1, Touch touch2)
     : this(recognizer, new CommonTouch(touch1), new CommonTouch(touch2))
 {
 }