Time for action – implementing a title screen
1. Download the
7089_08_GRAPHICSPACK.ZIP
file from the book's website and extract the files it contains to a temporary location.2. In Windows Explorer, select all of the
.png
files in the temporary folder and copy them to the clipboard.3. Switch back to Visual Studio, right-click on the Textures folder in the content project, and select Paste.
4. To the
TankBattlesGame
class' declarations area, add the following declarations:Texture2D titleScreen; int currentPlayer = 0; enum GameState { TitleScreen, Playing, GameOver } GameState gameState = GameState.TitleScreen;
5. In the
LoadContent()
method of theTankBattlesGame
class, remove the line that readsStartNewRound();
.6. At the bottom of the
LoadContent()
method of theTankBattlesGame
class, initialize thetitleScreen
texture field as follows:titleScreen = Content.Load<Texture2D>(@"Textures\TitleScreen");
7. In the
Update()
method of theTankBattlesGame
class, use the mouse to highlight everything...