Time for action – drawing the screen – the title screen

  1. Modify the Draw() method of Game1 to include the code necessary to draw the game's title screen after GraphicsDevice.Clear(Color.CornflowerBlue);
    if (gameState == GameStates.TitleScreen)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(titleScreen,
            new Rectangle(0, 0,
                this.Window.ClientBounds.Width,
                this.Window.ClientBounds.Height),
            Color.White);
        spriteBatch.End();
    }
  2. Run the game and verify that the title screen is displayed. You will not be able to start the game however, as we haven't written the Update() method yet.
  3. Stop the game by pressing Alt + F4.
    Time for action – drawing the screen – the title screen

What just happened?

The title screen is drawn with ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.