-1

http://msdn.microsoft.com/en-us/library/bb203902.aspx

I've got a title screen called 'TitleScreen' in my game.

I'm following the up^ linked tutorial, but on this argument, I want to make it so

        if (newState.IsKeyDown(Keys.Space))
        {
            // If not down last update, key has just been pressed.
            if (!oldState.IsKeyDown(Keys.Space))
            {
                backColor = 
                    new Color(backColor.R, backColor.G, (byte)~backColor.B);
            }
        }

If spacebar is pressed, the 'TitleScreen' opacity turns to 0 or it completely disappears? Would it be possible to alter the
"backColor = new Color(backColor.R, backColor.G, (byte)~backColor.B);" command in such a way?

Any help is appreciated, thank you!

Brunaldo
  • 49
  • 2
  • 7

1 Answers1

0

Your question is not well phrased, and doesn't conform to your title. Is this a question about detecting a key press, or altering the color of something? (I would've mentioned this in a comment but I don't have enough rep to comment yet)

Anyway, yes it should be possible to alter a color through a key press in the way that you've shown. Although if it doesn't query that color again then that change might not be apparent. You may need to have it re-initialize somehow after changing the color. The way you have it shown there it would toggle the component in the color each time you pressed the button.

Nic Foster
  • 2,864
  • 1
  • 27
  • 45
  • NOOO, I want to make it so, if I press 'spacebar' the 'TitleScreen' disappears, and just the game behind it is in view, NOT the 'TitleScreen'. – Brunaldo Jan 16 '12 at 21:55
  • If the titlescreen is just a texture that is displaying I would unload the title or quit drawing it, so you're not sending a draw call to a completely invisible texture. But yes, a simple but crude way to do it would be to fade out the titlescreen completely. In that case you don't want to use the 'B' component of color, you want to use the 'A' component instead. – Nic Foster Jan 17 '12 at 00:23