0

这会导致与其他对象发生碰撞并且无法正常工作,

我觉得这可能与我们如何为玩家旋转精灵有关,下面是我们用于旋转的代码

#region draw player

        if (player.facing == 4)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 1.5708f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);

        else if (player.facing == 3)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 4.712389f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);

        else if (player.facing == 1)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 0, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);

        else if (player.facing == 2)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 3.14593f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);

        else if (player.facing == 5)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 0.785398163f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);

        else if (player.facing == 6)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 2.094395102f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);
        else if (player.facing == 7)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 3.839724354f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);
        else if (player.facing == 8)

            spriteBatch.Draw(player.txr, player.drawRect, null, Color.White, 5.497787144f, new Vector2(player.drawRect.Width / 2, player.drawRect.Height / 2), SpriteEffects.None, 0);
        #region DEBUG
        //spriteBatch.Draw(Door.txr, player.drawRect, Color.White);
        //spriteBatch.Draw(Door.txr, player1.drawRect, Color.White);
        //spriteBatch.Draw(Door.txr, player2.drawRect, Color.White);
        //spriteBatch.Draw(Door.txr, player3.drawRect, Color.White);
        #endregion
4

1 回答 1

0

绘制一个精灵批次只会在该旋转中渲染您的精灵。播放器的碰撞盒以及如何处理它是一个单独的问题。您必须使用与绘制相同的旋转来转换您的玩家碰撞盒。

于 2013-05-10T11:27:59.043 回答