What's on the menu?
Main menus may have disappeared in many applications, but they are still alive and well in games. The main menu gives the player a chance to decide what to do once the game has loaded. We are going to create a simple menu that allows the player to start the game, display the credits, or exit the game.
Creating the menu
Our menu will be built out of two components. First, we will load an image to use as the background. Next, we will load additional images to use as UI buttons. Together, these images will create a screen that will allow the player to navigate our game.
We will start by defining a sprite to represent the menu. Add the following line of code to the variable declarations in RoboRacer2D.cpp
:
Sprite* menuScreen;
Next, we will instantiate the menu in the LoadTextures
function. Add the following code to LoadTextures
:
menuScreen = new Sprite(1); menuScreen->SetFrameSize(800.0f, 600.0f); menuScreen->SetNumberOfFrames(1); menuScreen->AddTexture("resources...