methods that are specified as event handlers.
Create the event handlers by implementing the following methods in the class:
// Handles "Play" menu item selection
void StartGameMenuEntrySelected(object sender, EventArgs e)
ScreenManager.AddScreen(new InstructionsScreen(), null);
// Handles "Exit" menu item selection
protected override void OnCancel(PlayerIndex playerIndex)
Notice the difference between the two method signatures. While StartGameMenuEntrySelected is an actual event handler, OnCancel is actually called from a different event handler, which is also called OnCancel and is implemented in the base class. Also, notice that StartGameMenuEntrySelected’s body adds a screen which we will soon create.
Override the UpdateMenuEntryLocations method. This allows a menu screen to control the location of its menu items:
protected override void UpdateMenuEntryLocations()
foreach (var entry in MenuEntries)
var position = entry.Position;
position.Y += 60;
entry.Position = position;
Create a new class called InstructionsScreen in the Screens folder you have previously created.
Open the new class file and add the following using statements at the top of the file.
Change the new class to derive from the GameScreen class:
Page | 26