Setting a leader from a sprite array
Posted
by
Craig
on Game Development
See other posts from Game Development
or by Craig
Published on 2012-12-08T16:25:15Z
Indexed on
2012/12/08
17:21 UTC
Read the original article
Hit count: 251
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;
© Game Development or respective owner