public override void HandleInput(InputState input) { PlayerIndex playerIndex; if (MenuBindings.IsMenuCancel(ControllingPlayer, out playerIndex)){ ScreenManager.Game.Exit(); } base.HandleInput(input); }
/// <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) { }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { // Move to the previous menu entry? if (MenuBindings.IsMenuUp(ControllingPlayer)) { selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (MenuBindings.IsMenuDown(ControllingPlayer)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) selectedEntry = 0; } // Accept or cancel the menu? We pass in our ControllingPlayer, which may // either be null (to accept input from any player) or a specific index. // If we pass a null controlling player, the InputState helper returns to // us which player actually provided the input. We pass that through to // OnSelectEntry and OnCancel, so they can tell which player triggered them. PlayerIndex playerIndex; if (MenuBindings.IsMenuSelect(ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); click.Play(); } else if (MenuBindings.IsMenuCancel(ControllingPlayer, out playerIndex)) { back.Play(); OnCancel(playerIndex); } else if (MenuBindings.IsMenuRight(ControllingPlayer)) { OnRightEntry(selectedEntry, playerIndex); click.Play(); } else if (MenuBindings.IsMenuLeft(ControllingPlayer)) { OnLeftEntry(selectedEntry, playerIndex); click.Play(); } else if (MenuBindings.IsStart(ControllingPlayer, out playerIndex)) { OnStartEntry(selectedEntry, playerIndex); click.Play(); } }
/// <summary> /// Respond to player input. This will only be called when the gameplay screen is active. /// </summary> /// <param name="input">The current input state.</param> public override void HandleInput(InputState input) { // Handle input. // Pause Handling if (GameplayBindings.IsPauseGame(ControllingPlayer)) { ScreenManager.AddScreen(new PauseScreen(), ControllingPlayer); } // Debug Handling #if DEBUG if (DebugBindings.IsSwitchCamera(ControllingPlayer)){ currentCameraIndex++; if (currentCameraIndex == cameraEntities.Count) { currentCameraIndex = 0; } cameraEntities[currentCameraIndex].ResetCamera(); } #endif }