X hits on this document

263 views

0 shares

0 downloads

0 comments

46 / 102

CatapultState currentState;

public CatapultState CurrentState

{

   get { return currentState; }

   set { currentState = value; }

}

105.

Add the following constructors to the catapult class:

C#

public Catapult(Game game)

   : base(game)

{

   curGame = (CatapultGame)game;

}

public Catapult(Game game, SpriteBatch screenSpriteBatch,

   string IdleTexture,

   Vector2 CatapultPosition, SpriteEffects SpriteEffect, bool IsAI)

   : this(game)

{

   idleTextureName = IdleTexture;

   catapultPosition = CatapultPosition;

   spriteEffects = SpriteEffect;

   spriteBatch = screenSpriteBatch;

   isAI = IsAI;

   // splitFrames = new Dictionary<string, int>();

   // animations = new Dictionary<string, Animation>();

}

The second constructor contains some lines that are commented out, which refer to members that we will only add at a later stage.

106.

In the Catapult class, override the DrawableGameComponent’s Initialize method:

C#

public override void Initialize()

{

   // Define initial state of the catapult

   currentState = CatapultState.Idle;

   // Load the idle texture

   idleTexture = curGame.Content.Load<Texture2D>(idleTextureName);

   base.Initialize();

}

Page | 46

Document info
Document views263
Page views263
Page last viewedWed Dec 07 23:12:08 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments