X hits on this document

279 views

0 shares

0 downloads

0 comments

27 / 102

C#

class InstructionsScreen : GameScreen

{

}

53.

Add the following field to the class:

C#

Texture2D background;

54.

Add the following constructor to the class. Since this screen will respond to user taps on the display, we have to enable tap gestures:

C#

public InstructionsScreen()

{

   EnabledGestures = GestureType.Tap;

   TransitionOnTime = TimeSpan.FromSeconds(0);

   TransitionOffTime = TimeSpan.FromSeconds(0.5);

}

55.

Override the LoadContent method to load the instruction set image:

C#

public override void LoadContent()

{

   background = Load<Texture2D>("Textures/Backgrounds/instructions");           

}

56.

Override the Draw method to display the image we have previously loaded:

C#

public override void Draw(GameTime gameTime)

{

   SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

   spriteBatch.Begin();

   // Draw Background

   spriteBatch.Draw(background, new Vector2(0, 0),

           new Color(255, 255, 255, TransitionAlpha));

   spriteBatch.End();

}

57.

Override the HandleInput method, which is inherited from the GameScreen class and allows a screen to respond to user input:

C#

public override void HandleInput(InputState input)

{

Page | 27

Document info
Document views279
Page views279
Page last viewedFri Dec 09 08:42:16 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments