0

I create a button in the option menu, and I want keep the same key to the same button. Which is RightMouse button. I want to be able to click and set Fullscreen true and set it false after it loads, but I don't understand how to this is without it freaking out.

How do I keep the same key from clicking twice once the user clicked it. During the phase of changing enums? I have a button behind one enum that uses the exact same key, but it actives when I click a button to get to it.

            if (option.Button1.Contains(MousePosition))
                {
                    if (mouseState.RightButton == ButtonState.Pressed)
                    {
                        graphics.IsFullScreen = true;
                        graphics.ApplyChanges();
                    }
                    else if (mouseState.RightButton == ButtonState.Pressed)
                    {
                        graphics.IsFullScreen = false;
                        graphics.ApplyChanges();
                    }
                }
Howllo
  • 33
  • 7
  • `graphics.IsFullScreen = !graphics.IsFullScreen`? And you'll need to remember the previous state... You should start learning programming with something easier than games. – Athari Aug 21 '14 at 00:31
  • @Athari I'm creating entire game without a tutorial. Which is a flood runner, with my team. This is as basic as you get. Right now I'm about average programmer. I can program entire consoles. I know what I'm doing. There are just little holes in my programming skills. – Howllo Aug 21 '14 at 00:38

1 Answers1

2

As mentioned in the comment, you need to just switch the state.

if (option.Button1.Contains(MousePosition))
{
   if (mouseState.RightButton == ButtonState.Pressed)
    {
       graphics.IsFullScreen = !graphics.IsFullScreen;
       graphics.ApplyChanges();
    }
 }
Hassan
  • 5,360
  • 2
  • 22
  • 35
  • Hmm. For some reason I didn't know that ! was switch. Even know I use it some times, but how do I keep mouse click again once I change enum. When I use LeftButton it kinda double clicks or goes "Through" the enum and clicks again. How do I keep it from click twice once I change enums? – Howllo Aug 21 '14 at 00:42
  • Have you handled `mouseState.LeftButton`? which `enum` you are referring? – Hassan Aug 21 '14 at 00:49
  • When I change from `GameState.Menu:` to case `GameState.Option:` – Howllo Aug 21 '14 at 01:02
  • Sorry. I am not able to understand automatic double click of mouse when you press LeftButton. I think you should use `GetState()` of [Mouse](http://msdn.microsoft.com/en-us/library/Microsoft.Xna.Framework.Input.Mouse_methods.aspx) class, to get the current state. – Hassan Aug 21 '14 at 01:14
  • https://www.youtube.com/watch?v=XjxSCRJgqCM this. Goes straight into fullscreen if I use the same button. – Howllo Aug 21 '14 at 01:21
  • Check solution [here](http://stackoverflow.com/questions/9712932/2d-xna-game-mouse-clicking). Use `ButtonState.Released` to make sure then full screen action is done. – Hassan Aug 21 '14 at 01:35