/// <summary> /// Checks to see if this is the first time the directional pad has been pressed. For instance, if the DP is /// pressed and then held down, on subsequent calls this method will return FALSE. /// </summary> /// <returns>True if this is the first time the dp has been pressed, false otherwise.</returns> public static bool isFirstPressJSDP() { if (JSDirectionalPad() != DirectionalPadPositions.neutral) { if (lastDPPosition == JSDirectionalPad()) { return(false); } else { lastDPPosition = JSDirectionalPad(); return(true); } } //if !neutral lastDPPosition = DirectionalPadPositions.neutral; return(false); }
/// <summary> /// Checks to see if the given direction is pressed for the first time on the directional pad. /// </summary> /// <param name="d">The direction to check.</param> /// <returns>True if the direction is pressed for the first time, otherwise false.</returns> public static bool isFirstPressJSDP(DirectionalPadPositions d) { if (JSDirectionalPad() != DirectionalPadPositions.neutral) { if (JSDirectionalPad() == d) { if (lastDPPosition == d) { return(false); } lastDPPosition = d; return(true); } //if pressing the indicated direction else { return(false); } } //if !neutral //if neutral next press will pass this function and return true. lastDPPosition = DirectionalPadPositions.neutral; return(false); }
/// <summary> ///Resets variables so that the next press on the dp ///will be the first press, even if it actually isn't. /// </summary> public static void resetJSDP() { lastDPPosition = DirectionalPadPositions.neutral; }