Easily access the current update time step delta, which defaults to 0.05 (20 updates/sec).
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Entities Time
Namespace: DeltaEngine.Entities
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Time type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Time | Initializes a new instance of the Time class |
Methods
Name | Description | |
---|---|---|
CheckEvery |
Allows to check in huge intervals. Should only be used with interval values above Delta,
otherwise it will always return true as the Total time is only updated once per Update tick.
We subtract Delta since Total already includes this update tick's Delta.
View code on GitHub |
Fields
Name | Description | |
---|---|---|
SpeedFactor |
Properties
Name | Description | |
---|---|---|
Delta | ||
IsPaused | ||
RapidUpdateDelta | ||
Total |
Remarks
Examples
[Test] public void CheckEveryIsFalseIfItDidNotCrossTheIntervalThisFrame() { Time.Total = 0.4f; Time.Delta = 0.2f; Assert.IsFalse(Time.CheckEvery(0.5f)); }
[Test] public void CheckEveryIsTrueIfItDidCrossTheIntervalThisFrame() { Time.Total = 0.6f; Time.Delta = 0.2f; Assert.IsTrue(Time.CheckEvery(0.5f)); }
[Test] public void PauseTimeShouldNotUpdateAnyEntityAnymore() { var entities = new MockEntitiesRunner(typeof(EntitiesRunnerTests.IncrementCounter)); var entity = new MockEntity().Add(0).Start<EntitiesRunnerTests.IncrementCounter>(); Assert.AreEqual(0, entity.Get<int>()); entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); Time.SpeedFactor = 0; entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); Time.SpeedFactor = 1; }
See Also