Time for action – viewing the Sprite and Camera classes in action
In the declarations area of the Game1 class, add a declaration for a temporary sprite object:
// Temporary Demo Code Begin Sprite tempSprite; Sprite tempSprite2; // Temporary Demo Code End
In the
LoadContent()
method of the Game1 class, initialize the temporary sprite and the Camera class:// Temporary Demo Code Begin tempSprite = new Sprite( new Vector2(100, 100), spriteSheet, new Rectangle(0, 64, 32, 32), Vector2.Zero); tempSprite2 = new Sprite( new Vector2(200,200), spriteSheet, new Rectangle(0, 160, 32, 32), Vector2.Zero); // Temporary Demo Code End
In the
Draw()
method of the Game1 class, draw the temporary sprite:// Temporary Demo Code spriteBatch.Begin(); tempSprite.Draw(spriteBatch); tempSprite2.Draw(spriteBatch); spriteBatch.End(); // Temporary Demo Code End
In the
Update()
method of the Game1 class, add temporary input handling to allow the sprite and the camera to be moved:// Temporary...