///----------------------------------------------------------------------------------
    /// <summary>
    /// 更新某个手指的位置信息,用来判断手势的输出
    /// </summary>
    ///----------------------------------------------------------------------------------
    private void UpdateFingers()
    {
        if (mInputProvider != null)
        {
            mInputProvider.Update();
        }

        mTouches.Clear();
        for (int i = 0; i < mFingers.Length; ++i)
        {
            Finger  finger = mFingers[i];
            Vector2 pos    = Vector2.zero;
            bool    IsDown = false;

            mInputProvider.GetInputState(finger.fingerIndex, out IsDown, out pos);
            finger.Update(IsDown, pos);

            if (finger.IsDown())
            {
                mTouches.Add(finger);
            }
        }

        for (int i = 0; i < mRecognizer.Count; i++)
        {
            mRecognizer[i].Update();
        }
    }
Exemple #2
0
    void UpdatePerFinger()
    {
        for (int i = 0; i < EasyFingerGestues.instance.mFingers.Length; i++)
        {
            Finger      finger  = EasyFingerGestues.instance.mFingers[i];
            T           gesture = _gestures[0];
            CFingerList touches = tempTouches;
            touches.Clear();


            if (finger.IsDown())
            {
                touches.Add(finger);
            }

            if (gesture.state == GestureState.Ready)
            {
                if (CanBegin(gesture, touches))
                {
                    Begin(gesture, touches);
                }
            }

            UpdateGesture(gesture, touches);
        }
    }
Exemple #3
0
        public void Update()
        {
            if (Time.frameCount > _lastUpdatedFrame)
            {
                // loop the current touches to refresh our knowledge of them
                for (int i = 0; i < Input.touchCount; ++i)
                {
                    var  touch = Input.GetTouch(i);
                    bool down  = touch.phase != TouchPhase.Canceled || touch.phase != TouchPhase.Ended;
                    if (down)
                    {
                        // This logic is unbelievably convoluted, but I can't find a simpler way to express
                        // the desired input behavior without creating new Dictionaries every frame.
                        if (first == null && !Finger.Matches(second, touch))
                        {
                            first = new Finger(touch);
                        }
                        if (!Finger.Matches(first, touch) && !Finger.Matches(second, touch))
                        {
                            second = new Finger(touch);
                        }

                        // just update the remaining
                        if (first != null)
                        {
                            first.MarkAsDown(touch);
                        }
                        if (second != null)
                        {
                            second.MarkAsDown(touch);
                        }
                    }
                }
                if (!Finger.IsDown(first))
                {
                    first = null;
                }
                if (!Finger.IsDown(second))
                {
                    second = null;
                }
                _lastUpdatedFrame = Time.frameCount;
            }
        }