Partager via


Game.IsFixedTimeStep Property

Gets or sets a value indicating whether to use fixed time steps.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework.Game (in microsoft.xna.framework.game.dll)

Syntax

public bool IsFixedTimeStep { get; set; }

Property Value

true if using fixed time steps; false otherwise.

Remarks

The default value for IsFixedTimeStep is true.

A fixed-step Game tries to call its Update method on the fixed interval specified in TargetElapsedTime. Setting Game.IsFixedTimeStep to true causes a Game to use a fixed-step game loop. A new XNA project uses a fixed-step game loop with a default TargetElapsedTime of 1/60th of a second.

In a fixed-step game loop, Game calls Update once the TargetElapsedTime has elapsed. After Update is called, if it is not time to call Update again, Game calls Draw. After Draw is called, if it is not time to call Update again, Game idles until it is time to call Update.

If Update takes too long to process, Game sets IsRunningSlowly to true and calls Update again, without calling Draw in between. When an update runs longer than the TargetElapsedTime, Game responds by calling Update extra times and dropping the frames associated with those updates to catch up. This ensures that Update will have been called the expected number of times when the game loop catches up from a slowdown. You can check the value of IsRunningSlowly in your Update if you want to detect dropped frames and shorten your Update processing to compensate. You can reset the elapsed times by calling ResetElapsedTime.

When your game pauses in the debugger, Game will not make extra calls to Update when the game resumes.

See Also

Reference

GameTime.IsRunningSlowly Property
Game.TargetElapsedTime Property
Game Class
Game Members
Microsoft.Xna.Framework Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP