Time for action – adding the ShotManager class
Add a new class called ShotManager to the Asteroid Belt Assault project.
Add the
using
directives to the top of the class file:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Add declarations to the ShotManager class:
public List<Sprite> Shots = new List<Sprite>(); private Rectangle screenBounds; private static Texture2D Texture; private static Rectangle InitialFrame; private static int FrameCount; private float shotSpeed; private static int CollisionRadius;
Add a constructor to the the ShotManager class:
public ShotManager( Texture2D texture, Rectangle initialFrame, int frameCount, int collisionRadius, float shotSpeed, Rectangle screenBounds) { Texture = texture; InitialFrame = initialFrame; FrameCount = frameCount; CollisionRadius = collisionRadius; this.shotSpeed = shotSpeed; this.screenBounds = screenBounds; }
What just happened?
ShotManager maintains a list...