如何Stack<T>
按索引访问项目?
如何修复我正在尝试制作的游戏的错误?
private void UpdateDiamonds(GameTime gameTime)
{
for (int i = 0; i < diamonds.Count; ++i)
{
Gem ruby = diamonds[i];
ruby.Update(gameTime);
if (ruby.BoundingCircle.Intersects(Player.BoundingRectangle))
{
diamonds.Pop(i--);
OnGemCollected(ruby, Player);
}
}
}
这些是我得到的错误:
Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.Stack<>
No overload for method 'Pop' takes 1 arguments