示例#1
0
        // This will return the recorded position of the current finger when it was at 'targetAge'
        public Vector2 GetSnapshotScreenPosition(float targetAge)
        {
            var screenPosition = ScreenPosition;

            NewLeanSnapshot.TryGetScreenPosition(Snapshots, targetAge, ref screenPosition);

            return(screenPosition);
        }
示例#2
0
        // Records a snapshot of the current finger
        public void RecordSnapshot()
        {
            // Get an unused snapshot and set it up
            var snapshot = NewLeanSnapshot.Pop();

            snapshot.Age            = Age;
            snapshot.ScreenPosition = ScreenPosition;

            // Add to list
            Snapshots.Add(snapshot);
        }
示例#3
0
        // Add a finger based on index, or return the existing one
        private void AddFinger(int index, Vector2 screenPosition)
        {
            var finger = FindFinger(index);

            // No finger found?
            if (finger == null)
            {
                var inactiveIndex = FindInactiveFingerIndex(index);

                // Use inactive finger?
                if (inactiveIndex >= 0)
                {
                    finger = InactiveFingers[inactiveIndex]; InactiveFingers.RemoveAt(inactiveIndex);

                    // Inactive for too long?
                    if (finger.Age > TapThreshold)
                    {
                        finger.TapCount = 0;
                    }

                    // Reset values
                    finger.Age     = 0.0f;
                    finger.Set     = false;
                    finger.LastSet = false;
                    finger.Tap     = false;
                    finger.Swipe   = false;
                }
                // Create new finger?
                else
                {
                    finger = new NewLeanFinger();

                    finger.Index = index;
                }

                finger.StartScreenPosition = screenPosition;
                finger.LastScreenPosition  = screenPosition;
                finger.ScreenPosition      = screenPosition;
                finger.StartedOverGui      = finger.IsOverGui;

                Fingers.Add(finger);
            }

            finger.Set            = true;
            finger.ScreenPosition = screenPosition;

            // Record?
            if (RecordFingers == true)
            {
                // Too many snapshots?
                if (RecordLimit > 0.0f)
                {
                    if (finger.SnapshotDuration > RecordLimit)
                    {
                        var removeCount = NewLeanSnapshot.GetLowerIndex(finger.Snapshots, finger.Age - RecordLimit);

                        finger.ClearSnapshots(removeCount);
                    }
                }

                // Record snapshot?
                if (RecordThreshold > 0.0f)
                {
                    if (finger.Snapshots.Count == 0 || finger.LastSnapshotScreenDelta.magnitude >= RecordThreshold)
                    {
                        finger.RecordSnapshot();
                    }
                }
                else
                {
                    finger.RecordSnapshot();
                }
            }
        }