ElapsedGameTime如何工作,以便隨着遊戲的進行,依賴於它的變量不會增加?例如,這種方法:C#XNA GameTime.ElapsedGameTime用於均衡不同的計算機?
private void Keyboard(GameTime gameTime)
{
float rotXZ = 0;
float turningSpeed = (float)gameTime.ElapsedGameTime.TotalMilliseconds/1000.0f;
turningSpeed *= 1.6f * gameSpeed;
KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.Right))
rotXZ += turningSpeed;
if (keyState.IsKeyDown(Keys.Left))
rotXZ -= turningSpeed;
}
我是從解釋我們使用ElapsedGameTime所以旋轉速度是快/慢的電腦相同的來源,但我不明白這是如何工作?
感謝
FYI:.TotalMilliseconds/1000相當於:.TotalSeconds –