I really need some help to find the reason why not any of my Asteroids sprites are visible on the screen after I added som code to dedect collision. My suspect is that it has to do in the collision method and that the sprites are removed from the list from the beginning!? The Spaceship is visible.
In my manager class I have this method for checking the collision:
public void CollisionControl(Spaceship spaceShip)
{
for (int i = 0; i < asteroidList.Count(); i++)
{
if (asteroidList.ElementAt(i).Bounds().Intersects(spaceShip.Bounds()))
{
asteroidList.RemoveAt(i);
i--;
}
}
}
And then from the Game1 class I call this manager from the Update Method like this:
asteroidManager.CollisionControl(spaceship);
And finally in the SpaceShip class and the Asteroids Class I have this code:
// Bounds
public Rectangle Bounds()
{
//return new Rectangle((int)(position.X - orgin.X), (int)(position.Y - orgin.Y), texture.Width, texture.Height);
return new Rectangle(0,0,60,60);
}
// Draw method
public void Draw(SpriteBatch spriteBatch)
{
//spriteBatch.Draw(texture, position, new Rectangle(0,0, (int)texture.Width, (int)texture.Height) , Color.White, rotation, orgin, 1, SpriteEffects.None, 0);
spriteBatch.Draw(texture, position, null, Color.White, rotation, orgin, 1, SpriteEffects.None, 0);
}
Help is really preciated! I'm doing a hand in task that I need to complete soon! Thanks!