碰撞Xna c#

时间:2015-12-15 04:44:36

标签: c# xna

我在小游戏上工作,我的碰撞有问题

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();
}

你能帮助我吗?

0 个答案:

没有答案