Time for action – building the Gemstone class
Add a new class file called
Gemstone.cs
to the Gemstone Hunter project.Add the following
using
directives to the Gemstone class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Tile_Engine;
Modify the declaration of the Gemstone class to make the class public, and derive it from the GameObject class:
public class Gemstone : GameObject
Add a constructor for the Gemstone class:
#region Constructor public Gemstone(ContentManager Content, int cellX, int cellY) { worldLocation.X = TileMap.TileWidth * cellX; worldLocation.Y = TileMap.TileHeight * cellY; frameWidth = TileMap.TileWidth; frameHeight = TileMap.TileHeight; animations.Add("idle", new AnimationStrip( Content.Load<Texture2D>(@"Textures\Gem"), 48, "idle")); animations["idle"].LoopAnimation = true; animations["idle"].FrameLength = 0.15f; PlayAnimation...