Time for action – creating the MarsRunnerPlayScreen class
To create a new gameplay screen for Mars Runner, perform the following steps:
1. Add a new class file to the
Screens
folder of theMars Runner
project. Name the class fileMarsRunnerPlayScreen.cs
.2. Modify the namespace line in the newly created class by removing
.Screens
from the end of the namespace. The new line should read as follows:namespace Mars_Runner
3. Add the following
using
directives at the beginning of the class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input;
4. Modify the declaration of the class to derive it from the
GameScreen
class as follows:class MarsRunnerPlayScreen : GameScreen
5. Add fields to the
MarsRunnerPlayScreen
class as follows:#region Fields ContentManager content; Random random = new Random(); #endregion
6. In the
MainMenuScreen
class, inside theHandle Input
region, modify thePlayGameMenuEntrySelected...