Setting a leader from a sprite array
- by Craig
I'm looking to set a leader from an array of sprites, I keep on getting a NullReferenceException was unhandled error from within my main game class when calling the UpdateMouse Method. What have I dont wrong here?
class MouseSprite
{
Random random = new Random();
private MouseSprite leader;
public void UpdateBoundaryBox()
{
mouseBounds.X = (int)mousePosition.X - mouseTexture.Width / 2; mouseBounds.Y = (int)mousePosition.Y - mouseTexture.Height / 2;
}
public void UpdateMouse(Vector2 position, MouseSprite [] mice, int numberMice, int index)
{
Vector2 catPosition = position;
int enemies = numberMice;
this.alive = true;
mice[random.Next(0, mice.Length)] = leader;