Time for action – building the Gemstone class
Add a new class called
Gemstone
to the Gemstone Hunter project.Add the following
Imports
directive to the top of theGemstone
class file:Imports Tile_Engine
Add an
Inherits
line to the class declaration to derive it fromGameObject
:Public Class Gemstone Inherits GameObject
Add a constructor for the
Gemstone
class:#Region "Constructor" Public Sub New( content As ContentManager, cellX As Integer, cellY As Integer) WorldLocation = New Vector2( TileMap.TileWidth * cellX, TileMap.TileHeight * cellY) _frameWidth = TileMap.TileWidth _frameHeight = TileMap.TileHeight _animations.Add("idle", New AnimationStrip( Content.Load(Of Texture2D)("Textures\Gem"), 48, "idle")) _animations("idle").LoopAnimation = True _animations("idle").FrameLength = 0.15 PlayAnimation("idle") DrawDepth = 0.875f CollisionRectangle = New Rectangle(9, 24, 30, 24) ...