X hits on this document

212 views

0 shares

0 downloads

0 comments

30 / 102

65.

This new class resembles the MainMenuScreen class, except for it having an associated background screen. Change the newly created class using the following code:

C#

class PauseScreen : MenuScreen

{

   GameScreen backgroundScreen;

   public PauseScreen(GameScreen backgroundScreen)

       : base(String.Empty)

   {

       IsPopup = true;

       this.backgroundScreen = backgroundScreen;

       // Create our menu entries.

       MenuEntry startGameMenuEntry = new MenuEntry("Return");

       MenuEntry exitMenuEntry = new MenuEntry("Exit");

       // Hook up menu event handlers.

       startGameMenuEntry.Selected += StartGameMenuEntrySelected;

       exitMenuEntry.Selected += OnCancel;

       // Add entries to the menu.

       MenuEntries.Add(startGameMenuEntry);

       MenuEntries.Add(exitMenuEntry);

   }

   protected override void UpdateMenuEntryLocations()

   {

       base.UpdateMenuEntryLocations();

       foreach (var entry in MenuEntries)

       {

           var position = entry.Position;

           position.Y += 60;

           entry.Position = position;

       }

   }

   void StartGameMenuEntrySelected(object sender, EventArgs e)

   {

       backgroundScreen.ExitScreen();

       ExitScreen();

   }

Page | 30

Document info
Document views212
Page views212
Page last viewedFri Dec 02 22:34:37 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments