/// <summary> /// Gets the swipe direction of a manipulation. /// </summary> /// <param name="cumulativeValue"> /// The cumulative Value. /// </param> /// <param name="axis"> /// The axis. /// </param> /// <param name="threshold"> /// The threshold to check. /// </param> /// <returns> /// The <see cref="SwipeDirection"/>. /// </returns> public static SwipeDirection GetSwipeDirection(this double cumulativeValue, SwipeAxis axis, double threshold) { switch (axis) { case SwipeAxis.X: if (cumulativeValue >= threshold) { return(SwipeDirection.Right); } if (cumulativeValue <= -threshold) { return(SwipeDirection.Left); } break; case SwipeAxis.Y: if (cumulativeValue >= threshold) { return(SwipeDirection.Up); } if (cumulativeValue <= -threshold) { return(SwipeDirection.Down); } break; } return(SwipeDirection.None); }
/// <summary> /// Gets the the amount of movement in a given direction specificed by the given swipe axis /// (either X or Y) /// Inputs /// </summary> /// <param name="touch">Touch to get movement from</param> /// <param name="direction">Direction to return movement from</param> /// <returns></returns> public static float GetTouchMovementInDirection(Touch touch, SwipeAxis direction) { switch (direction) { case SwipeAxis.X: return(GetDeltaTouchMovement(touch).x); case SwipeAxis.Y: return(GetDeltaTouchMovement(touch).y); default: //Invalid - return 0 movement return(0.0f); } }