Пример #1
0
        private void HandleFingerUp(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null && Shape != null && Shape.Points != null)
            {
                //Debug.Log("count " + fingerData.Points.Count);
                var minimum = Shape.ConnectEnds == true ? Shape.Points.Count + 1 : Shape.Points.Count;

                if (MinimumPoints > 0 && MinimumPoints < minimum)
                {
                    minimum = MinimumPoints;
                }

                if (fingerData.Points.Count >= minimum)
                {
                    if (OnDetected != null)
                    {
                        OnDetected.Invoke(fingerData);
                    }
                }
            }

            LeanFingerData.Remove(fingerDatas, finger, fingerDataPool);
        }
Пример #2
0
        protected virtual void Update()
        {
            if (fingerDatas != null)
            {
                for (var i = fingerDatas.Count - 1; i >= 0; i--)
                {
                    var fingerData = fingerDatas[i];
                    var finger     = fingerData.Finger;
                    var screenFrom = finger.GetSnapshotScreenPosition(finger.Age - LeanTouch.CurrentTapThreshold);
                    var screenTo   = finger.ScreenPosition;

                    if (Vector2.Distance(screenFrom, screenTo) > LeanTouch.CurrentSwipeThreshold / LeanTouch.ScalingFactor)
                    {
                        if (fingerData.Flicked == false && TestFinger(finger, screenFrom, screenTo) == true)
                        {
                            fingerData.Flicked = true;

                            HandleFingerSwipe(finger, screenFrom, screenTo);

                            // If multi-flicks aren't allowed, remove the finger
                            if (Check != CheckType.Multiple)
                            {
                                LeanFingerData.Remove(fingerDatas, finger);
                            }
                        }
                    }
                    else
                    {
                        fingerData.Flicked = false;
                    }
                }
            }
        }
Пример #3
0
        private void HandleFingerUp(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);
            var points     = fingerData.Points;

            LeanFingerData.Remove(fingerDatas, finger, fingerDataPool);

            if (Shape != null)
            {
                ranges.Clear();

                var min = Shape.Points.Count;
                var max = Shape.Points.Count;

                if (MinimumPoints > 0)
                {
                    min = MinimumPoints;
                }

                for (var i = max; i >= min; i--)
                {
                    if (Shape.ConnectEnds == true)
                    {
                        for (var j = 0; j < Shape.Points.Count; j++)
                        {
                            AddRange(j, j + i - 1);
                        }
                    }
                    else
                    {
                        var steps = Shape.Points.Count - i;

                        for (var j = 0; j <= steps; j++)
                        {
                            AddRange(j, j + i - 2);
                        }
                    }
                }

                foreach (var range in ranges)
                {
                    if (CalculateMatch(points, Shape.Points, DistanceThreshold, ErrorThreshold, range.x, range.y) == true)
                    {
                        if (onDetected != null)
                        {
                            onDetected.Invoke(finger);
                        }

                        return;
                    }
                }
            }
        }
Пример #4
0
        /// <summary>If you've set Use to ManuallyAddedFingers, then you can call this method to manually add a finger.</summary>
        public void AddFinger(LeanFinger finger)
        {
            if (Shape != null && Shape.Points != null && Shape.Points.Count > 1)
            {
                // Discard any existing FingerData for this finger
                LeanFingerData.Remove(fingerDatas, finger, fingerDataPool);

                if (Shape.ConnectEnds == true)
                {
                    // If the shape is connected then begin detection from every point, because we don't know where the user has begun drawing from yet.
                    for (var i = Shape.Points.Count - 1; i >= 0; i--)
                    {
                        AddFinger(finger, i);
                    }
                }
                else
                {
                    AddFinger(finger, 0);
                }
            }
        }
Пример #5
0
 /// <summary>If you've set Use to ManuallyAddedFingers, then you can call this method to manually remove a finger.</summary>
 public void RemoveFinger(LeanFinger finger)
 {
     LeanFingerData.Remove(fingerDatas, finger, fingerDataPool);
 }
Пример #6
0
 private void HandleFingerUp(LeanFinger finger)
 {
     LeanFingerData.Remove(fingerDatas, finger);
 }