我在小游戏上工作,我的碰撞有问题
if (keyboard.IsKeyDown(Keys.Up))
{
Rectangle newHitbox = new Rectangle(this.Hitbox.X, this.Hitbox.Y - this.Speed, this.Hitbox.Width, this.Hitbox.Height);
bool collide = false;
foreach (Mur wall in walls)
{
if (newHitbox.Intersects(wall.Hitbox))
{
collide = true;
break;
}
}
if (!collide)
this.Hitbox.Y-= this.Speed;
this.Direction = Direction.Up;
this.Animate();
}
你能帮助我吗?