X hits on this document

269 views

0 shares

0 downloads

0 comments

78 / 102

172.

Open the Catapult.cs under the "Catapult" folder and examine the class’s fields. Two fields are commented out using the prefix “UNCOMMENT”. Uncomment these fields to make them available. The field section should now look as follows:

C#

...

public string Name;

// In some cases the game need to start second animation while first animation is still running;

// this variable define at which frame the second animation should start

Dictionary<string, int> splitFrames;

Texture2D idleTexture;

Dictionary<string, Animation> animations;

SpriteEffects spriteEffects;

...

These new fields will be used to map animations to a specific name and to define important frames in the course of specific animations.

173.

Navigate to the Catapult class’s constructor and uncomment the final two lines. The constructor should now look as follows:

C#

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>();

}

174.

Navigate to the Catapult class’s Initialize method. Locate the comment “// TODO: Update hit offset” and change the code directly below it to the following:

C#

...

Vector2 projectileStartPosition;

if (isAI)

   projectileStartPosition = new Vector2(630, 340);

Page | 78

Document info
Document views269
Page views269
Page last viewedThu Dec 08 06:48:19 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments