I am coding pickups(coins, etc.) at the moment, but when you pick something up... it doesn't ly on the ground anymore.
But I am getting an exception: System.InvalidOperationException
. caused by: map.Remove()
, and thrown by the foreach
loop.
So, how do I remove the pickup correctly from the list?
foreach (CollisionTiles tile in map.CollissionTiles)
{
if (!tile.isTransparant)
player.Collision(tile.Rectangle, map.Width, map.Height);
else
{
if (player.PickUp(tile, map.Width, map.Height))
map.Remove(tile);
}
camera.Update(player.Position, map.Width, map.Height);
}
The map.Remove()
void:
public void Remove(CollisionTiles tile)
{
this.collissionTiles.Remove(tile);
}