X hits on this document

251 views

0 shares

0 downloads

0 comments

28 / 102

   foreach (var gesture in input.Gestures)

   {

       if (gesture.GestureType == GestureType.Tap)

       {

           ExitScreen();

           //ScreenManager.AddScreen(new GameplayScreen(), null);

       }

   }

   base.HandleInput(input);

}

The above method will cause the screen to be replaced with the actual gameplay screen. However, since we have yet to implement the gameplay screen class, and will not do so until the next exercise, that portion of the code is currently commented out.

58.

So far, we have created three screens and now it is time to make them visible. To do that, we are required to alter the game class CatapultGame. Open the CatapultGame.cs file from the solution explorer and delete all the content from the CatapultGame class.

59.

Add the following using statement in the top of the class file:

C#

using GameStateManagement;

60.

Add a pair of variable declarations to the beginning of the class:

C#

public class CatapultGame : Game

{

   GraphicsDeviceManager graphics;

   ScreenManager screenManager;

}

61.

Now add a constructor to the class which will add the screens created in previous steps to the screen manager:

C#

public CatapultGame()

{

   graphics = new GraphicsDeviceManager(this);

   Content.RootDirectory = "Content";

   // Frame rate is 30 fps by default for Windows Phone.

   TargetElapsedTime = TimeSpan.FromTicks(333333);

   //Create a new instance of the Screen Manager

   screenManager = new ScreenManager(this);

   Components.Add(screenManager);

   //Switch to full screen for best game experience

Page | 28

Document info
Document views251
Page views251
Page last viewedTue Dec 06 19:25:00 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments