Click or drag to resize
DigitalRuneVariableStepTimer Class
Controls the timing of a game or game component using variable time steps.
Inheritance Hierarchy
SystemObject
  DigitalRune.Game.TimingVariableStepTimer

Namespace: DigitalRune.Game.Timing
Assembly: DigitalRune.Game (in DigitalRune.Game.dll) Version: 1.4.0.0 (1.4.0.14427)
Syntax
public class VariableStepTimer : IGameTimer

The VariableStepTimer type exposes the following members.

Constructors
  NameDescription
Public methodVariableStepTimer
Initializes a new instance of the VariableStepTimer class.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnIdle
Raises the Idle event.
Protected methodOnTimeChanged
Raises the TimeChanged event.
Public methodReset
Stops the timer and resets the time to zero.
Public methodStart
Starts/resumes the timer.
Public methodStop
Pauses the timer.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyAccumulatedTime
Gets the accumulated time.
Public propertyClock
Gets or sets the clock.
Public propertyDeltaTime
Gets the elapsed game time since the last time step.
Public propertyFrameCount
Gets the number of frames since the start of the timer (= the number of TimeChanged events).
Public propertyIdleTime
Gets the idle time.
Public propertyIsRunning
Gets a value indicating whether the timer is running.
Public propertyLostTime
Gets the amount of time dropped in the current time step.
Public propertyMaxDeltaTime
Gets or sets the maximal amount of time for a time step.
Public propertyMinDeltaTime
Gets or sets the minimal size of a time step.
Public propertySpeed
Gets or sets the speed ratio at which the game time progresses.
Public propertyTime
Gets the game time.
Top
Events
  NameDescription
Public eventIdle
Occurs when application is idle.
Public eventTimeChanged
Occurs when the game time has advanced.
Top
Remarks

See IGameTimer for basic information about game timers.

The VariableStepTimer triggers a new time step (TimeChanged event) as soon as the last time step has finished. DeltaTime returns the elapsed time since the last time step.

MinDeltaTime (default: 0) can be used to set the minimal size of a time step. If MinDeltaTime is greater than 0 than the timer waits until at least MinDeltaTime has passed before the next time step is triggered. During the waiting time the Idle event is raised. IdleTime indicates the time to wait until the next time step.

MaxDeltaTime (default: MaxValue) can be used to set the maximal size of a time step. If the previous time step took longer than MaxDeltaTime, then the size of the time step will be limited to MaxDeltaTime. The time beyond this value will be ignored. LostTime indicates the time that has been dropped.

Memory Leaks: If a Clock is set and the timer is running, the game timer handles the TimeChanged event of the clock. This means, the clock stores a strong reference to the timer and might prevent the timer from being garbage collected. If the timer is not needed anymore, call Stop or set the property Clock tp to allow the timer to be garbage collected.

See Also