コード例 #1
0
 private void MovePlayer(Vector2 deltaDrag)
 {
     if (Mathf.Abs(deltaDrag.x) > Mathf.Abs(deltaDrag.y))
     {
         //// Horizontal
         if (deltaDrag.x > 0)
         {
             // Right
             SwipeRight.Invoke();
         }
         else
         {
             // Left
             SwipeLeft.Invoke();
         }
     }
     else
     {
         //// Vertical
         if (deltaDrag.y > 0)
         {
             // Up
             SwipeUp.Invoke();
         }
         else
         {
             // Down
             SwipeDown.Invoke();
         }
     }
 }
コード例 #2
0
        public bool OnTouch(View v, MotionEvent e)
        {
            var checkheight = v.Height <= 0 ? _defaultCheckHeight : v.Height * 0.04;

            if (e.ActionMasked == MotionEventActions.Move)
            {
                if (FirstYPrecision != 0 && SecondYPrecision == 0)
                {
                    SecondYPrecision = e.GetY();
                }
                if (FirstYPrecision == 0)
                {
                    FirstYPrecision = e.GetY();;
                }
            }
            if (e.ActionMasked == MotionEventActions.Up)
            {
                if (FirstYPrecision != 0 && SecondYPrecision != 0 && (FirstYPrecision - SecondYPrecision) > checkheight)
                {
                    try
                    {
                        SwipeUp.Invoke(null, null);
                    }
                    catch (Exception ex) { Console.WriteLine("SwipeUp Exeption" + ex.Message); }
                }
                if (FirstYPrecision != 0 && SecondYPrecision != 0 && (SecondYPrecision - FirstYPrecision) > 0)
                {
                    try
                    {
                        SwipeDown.Invoke(null, null);
                    }
                    catch (Exception ex) { Console.WriteLine("SwipeDown Exeption" + ex.Message); }
                }
                FirstYPrecision  = 0;
                SecondYPrecision = 0;
            }

            return(false);
        }
コード例 #3
0
ファイル: Swipable.cs プロジェクト: XaHDpE/pzl3d
 // invokers methods
 private static void InvokeSwipeUp(Vector2 delta)
 {
     SwipeUp?.Invoke(delta);
 }