コード例 #1
0
        void OnMove()
        {
            switch (pressCount)
            {
            case 1:
                if (Pressed)
                {
                    base.OnDrag(actions[0]);
                }
                else
                {
                    base.OnMouseMove(actions[0]);
                }
                break;

            case 2:
                var     d0 = actions[0].CanPosition;
                var     d1 = actions[1].CanPosition;
                Vector2 d  = d0 - d1;
                float   s  = d.x * d.x + d.y * d.y;
                s            = Mathf.Sqrt(s);
                DeltaPix     = s - CurrentScale;
                CurrentScale = s;
                DirPix       = s - StartScale;
                s           /= StartScale;
                CurScale     = s;
                var   v0 = RawPos0 - RawPos1;
                float a0 = MathH.atan(v0.x, v0.y); //原始角度
                var   a1 = MathH.atan(d.x, d.y);   //当前角度
                DirAngle   = a0 - a1;
                v0         = LastPos0 - LastPos1;
                a0         = MathH.atan(v0.x, v0.y);//上一帧角度
                DeltaAngle = a0 - a1;
                LastPos0   = d0;
                LastPos1   = d1;
                if (TowFingerMove != null)
                {
                    TowFingerMove(this);
                }
                break;

            case 3:
                LastPos0 = actions[0].CanPosition;
                LastPos1 = actions[1].CanPosition;
                LastPos2 = actions[2].CanPosition;
                if (ThreeFingerMove != null)
                {
                    ThreeFingerMove(this);
                }
                break;

            case 4:
                LastPos0 = actions[0].CanPosition;
                LastPos1 = actions[1].CanPosition;
                LastPos2 = actions[2].CanPosition;
                LastPos3 = actions[3].CanPosition;
                if (FourFingerMove != null)
                {
                    FourFingerMove(this);
                }
                break;

            case 5:
                LastPos0 = actions[0].CanPosition;
                LastPos1 = actions[1].CanPosition;
                LastPos2 = actions[2].CanPosition;
                LastPos3 = actions[3].CanPosition;
                LastPos4 = actions[4].CanPosition;
                if (FiveFingerMove != null)
                {
                    FiveFingerMove(this);
                }
                break;
            }
        }