我只是想知道,在制作游戏时,我注意到 IsRunningSlowly 的 GameTime 值在我的游戏有焦点时返回 false(应该如此),但是当我更改应用程序时,它变为 true。我什至做了一个空游戏,即使它失去焦点,IsRunningSlowly 的 GameTime 值也会返回 true。我想知道为什么它会这样做?只是我的电脑,还是 XNA 的创造者是这样设计的?帧速率看起来不错,但值是真实的。没什么大不了的,我只是真的很好奇!
[空游戏]
public class Game1 : Microsoft.Xna.Framework.Game
{
#region Constuctors
public Game1()
{
this.GraphicsManager = new Microsoft.Xna.Framework.GraphicsDeviceManager(this);
this.Content.RootDirectory = "Content";
}
#endregion
#region Overrides
protected override void LoadContent()
{
this.SpriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(this.GraphicsDevice);
base.LoadContent();
}
protected override void Update(Microsoft.Xna.Framework.GameTime GameTime)
{
System.Console.WriteLine(GameTime.IsRunningSlowly);
Microsoft.Xna.Framework.Input.KeyboardState Keyboard = Microsoft.Xna.Framework.Input.Keyboard.GetState();
if (Keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) this.Exit();
base.Update(GameTime);
}
protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
{
GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.CornflowerBlue);
base.Draw(gameTime);
}
#endregion
#region Variables
private Microsoft.Xna.Framework.GraphicsDeviceManager GraphicsManager { get; set; }
private Microsoft.Xna.Framework.Graphics.SpriteBatch SpriteBatch { get; set; }
#endregion
}