示例#1
0
 private void TouchEnded(int id, Vector2 touchPoint)
 {
     if (id < MaxTouches)
     {
         TouchData touch = Touches[id];
         if (touch.IsTouching)
         {
             touch.IsTouching = false;
             touch.End        = touchPoint;
             touch.EndTime    = Time.time;
             Process process = ProcessTouchEvent(id, touchPoint, TouchPhase.Ended);
             if (process == Process.Stop)
             {
                 TouchProcessed(id);
             }
             if ((!touch.WasProcessed && (process == Process.Continue)) && (!touch.HasType() && (touch.Duration < MaxTapTime)))
             {
                 touch.TapCount++;
                 TapDetected(touch);//点击次数判定处理
             }
             else
             {
                 touch.TapCount = 0;
             }
         }
     }
 }
示例#2
0
    private void TouchMoved(int id, Vector2 touchPoint)
    {
        if (id < MaxTouches)
        {
            TouchData touch = Touches[id];
            if (touch.IsTouching && !touch.WasProcessed)
            {
                touch.LastPos   = touch.End;
                touch.End       = touchPoint;
                touch.EndTime   = Time.time;
                touch.Duration += Time.deltaTime;
                Process process = ProcessTouchEvent(id, touchPoint, TouchPhase.Moved);
                if (process == Process.Stop)
                {
                    TouchProcessed(id);
                }
                if (!touch.WasProcessed && (process == Process.Continue))
                {
                    float num2 = 1f;
                    if (Screen.dpi != 0f)//每英寸分辨率点数
                    {
                        num2 = Screen.dpi / 160f;
                    }
                    float num = 10f * num2;

                    float num3 = Vector2.Distance(touch.End, touch.Start);
                    if (!touch.HasType() && (num3 >= num))
                    {
                        touch.Type = TouchData.TouchType.Swipe;
                        SwipeDetected(touch);
#if DEBUG_DRAW_ENABLE
                        m_touchPoints.Add(touchPoint);
#endif
                    }
                }
            }
        }
    }