【发布时间】:2014-12-07 04:41:01
【问题描述】:
我正在 XNA 中创建一个游戏,我需要一个碰撞检测逻辑:
public Rectangle boundingBox = new Rectangle((int)playerShipPos.X, (int)playerShipPos.Y, frameWidth, frameHeight);
this.boundingBox = new Rectangle((int)meteorPosPub.X, (int)meteorPosPub.Y, (int)meteorTexture.Width, (int)meteorTexture.Height);
for (int i = meteorList.Count - 1; i >= 0; i--)
{
meteorGenerator meteor = new meteorGenerator(Vector2.Zero);
if (meteorList[i].meteorPosPub.Y > 664)
{
meteorList.RemoveAt(i);
if (meteor.boundingBox.Intersects(playerShip.boundingBox))
{
meteorList.RemoveAt(i);
}
}
}
所以我想实现这个效果:如果玩家飞船接触到流星,流星就会隐藏并从列表中删除,但实际上什么也没发生。
【问题讨论】: