【发布时间】:2015-03-21 18:10:13
【问题描述】:
我正在使用 C# 和 XNA 编写游戏。我正在尝试平滑精灵旋转。这是我的代码:
protected void RotateSpriteTo(int rotateTo)
{
if (rotateGradus > 360)
rotateGradus = 0;
if (rotateTo > rotateGradus)
{
while (rotateTo > rotateGradus)
{
rotateGradus += 1;
rotate = (rotateGradus * (float)Math.PI) / 180;
}
}
else
{
while (rotateTo < rotateGradus)
rotateGradus -=1;
rotate = (rotateGradus * (float)Math.PI) / 180;
}
}
以及我如何调用这个方法,例如:
if (Keyboard.GetState().IsKeyDown(Keys.A))
{
squarePosition.X -= speed;
RotateSpriteTo(180);
}
但是精灵会立即旋转。我该如何解决?
【问题讨论】: