public void Update(GameTime gameTime, InputHelper Input) { //otherwise it would be possible that the cursor rectangle is still on a button eventhough the controller is in use cursor = Input.ControllerInUse ? new Rectangle(0, 0, 0, 0) : new Rectangle(Input.MouseCheckPosition().X, Input.MouseCheckPosition().Y, 1, 1); //if the cursor is over a button or the button is selected with a controller, the button will change color if (cursor.Intersects(startButton) || selectedButton == Buttons.Start) { startColor.A = MouseOverAlpha; if (Input.MouseButtonCheckPressed(true) || Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.A)) { Start = true; } } else startColor.A = StandardAlpha; if (cursor.Intersects(optionsButton) || selectedButton == Buttons.Options) { optionsColor.A = 200; if (Input.MouseButtonCheckPressed(true) || Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.A)) { Options = true; } } else optionsColor.A = 255; if (cursor.Intersects(exitButton) || selectedButton == Buttons.ExitGame) { exitColor.A = 200; if (Input.MouseButtonCheckPressed(true) || Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.A)) { ExitGame = true; } } else exitColor.A = 255; //scrolling through menu with controller if (Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickDown)) { if (selectedButton == Buttons.None) selectedButton = Buttons.Start; else selectedButton++; if (selectedButton == Buttons.None) selectedButton = Buttons.Start; } if (Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickUp)) { if (selectedButton == Buttons.None) selectedButton = Buttons.ExitGame; else if (selectedButton == Buttons.Start) selectedButton = Buttons.ExitGame; else selectedButton--; } }
public void Update(GameTime gameTime, InputHelper Input) { cursor = Input.ControllerInUse ? new Rectangle(0, 0, 0, 0) : new Rectangle(Input.MouseCheckPosition().X, Input.MouseCheckPosition().Y, 1, 1); if (cursor.Intersects(resumeButton) || selectedButton == Buttons.Resume) { resumeColor.A = 200; if (Input.MouseButtonCheckPressed(true) || Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.A)) { Resume = true; } } else resumeColor.A = 255; if (cursor.Intersects(optionsButton) || selectedButton == Buttons.Options) { optionsColor.A = 200; if (Input.MouseButtonCheckPressed(true) || Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.A)) { Options = true; } } else optionsColor.A = 255; if (cursor.Intersects(quitButton) || selectedButton == Buttons.Quit) { quitColor.A = 200; if (Input.MouseButtonCheckPressed(true) || Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.A)) { Quit = true; } } else quitColor.A = 255; if (Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickDown)) { if (selectedButton == Buttons.None) selectedButton = Buttons.Resume; else selectedButton++; if (selectedButton == Buttons.None) selectedButton = Buttons.Resume; } if (Input.GamePadCheckPressed(Microsoft.Xna.Framework.Input.Buttons.LeftThumbstickUp)) { if (selectedButton == Buttons.None) selectedButton = Buttons.Quit; else if (selectedButton == Buttons.Resume) selectedButton = Buttons.Quit; else selectedButton--; } }