/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { if (input.MenuSelect) { // Raise the accepted event, then exit the message box. if (Accepted != null) Accepted(this, EventArgs.Empty); ExitScreen(); } else if (input.MenuCancel) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) Cancelled(this, EventArgs.Empty); ExitScreen(); } }
/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { if (input.MenuSelect) { // Raise the accepted event, then exit the message box. if (Accepted != null) Accepted(this, EventArgs.Empty); ExitScreen(); } else if (input.MenuCancel) { // Raise the cancelled event, then exit the message box. if (Cancelled != null) Cancelled(this, EventArgs.Empty); ExitScreen(); } #if ANDROID foreach (var g in input.Gestures) { if (g.GestureType == GestureType.Tap) { if (Accepted != null) Accepted(this, EventArgs.Empty); ExitScreen(); } } #endif }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { #if ANDROID var touch = input.CurrentTouchState; if (touch.Count > 0) { Viewport viewport = ScreenManager.GraphicsDevice.Viewport; Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); Vector2 position = new Vector2(0f, viewportSize.Y * 0.55f); foreach(var t in touch) { // we have a touch event if (t.State == Microsoft.Xna.Framework.Input.Touch.TouchLocationState.Pressed) { var pos = t.Position; for (int i = 0; i < menuEntries.Count; i++) { // Draw text, centered on the middle of each line. Vector2 size = ScreenManager.Font.MeasureString(menuEntries[i].Text); position.X = viewportSize.X / 2f - size.X / 2f; var rect = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y); if (rect.Contains(pos)) { selectedEntry = i; OnSelectEntry(selectedEntry); break; } position.Y += ScreenManager.Font.LineSpacing; } } } } #endif // Move to the previous menu entry? if (input.MenuUp) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; audioManager.PlayCue("menuMove"); } // Move to the next menu entry? if (input.MenuDown) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; audioManager.PlayCue("menuMove"); } // Accept or cancel the menu? if (input.MenuSelect) { OnSelectEntry(selectedEntry); audioManager.PlayCue("menuSelect"); } else if (input.MenuCancel) { OnCancel(); } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { if (input == null) throw new ArgumentNullException("input"); if (input.PauseGame) { // If they pressed pause, bring up the pause menu screen. ScreenManager.AddScreen(new PauseMenuScreen()); } }
/// <summary> /// Allows the screen to handle user input. Unlike Update, this method /// is only called when the screen is active, and not when some other /// screen has taken the focus. /// </summary> public virtual void HandleInput(InputState input) { }