Foundation.GameTimeTracker

Used to calculate and record the time between update calls. Time between updates is recorded in both delta time (fraction of a second that has passed) and in milliseconds. A compound record of all update delta times is also recorded.

In an attempt to avoid large compound values between updates when a window is unfocused, any individual update which exceeds 0.16 seconds (between 6-7 FPS) will result in an update time of 0.


Example

var timeTracker = new Foundation.GameTimeTracker();
    timeTracker.update();

setTimeout(function(){
  timeTracker.update();
  console.log(timeTracker.delta)  // Approx 0.016
  console.log(timeTracker.millis) // Approx 16
  console.log(timeTracker.lifetimeDelta) // Approx 16
}, 16);

setTimeout(function(){
  timeTracker.update();
  console.log(timeTracker.delta)  // Approx 0.016
  console.log(timeTracker.millis) // Approx 16
  console.log(timeTracker.lifetimeMillis) // Approx 32
}, 16);

//etc.


Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/actors/_digest.ts'
  • '/foundation/core/actors/GameTimeTracker.ts'

Extends

This type extends:

An update() call will update the time tracking variables (if the actor is active).

equals check is not overridden from the base.

Implements

This type does not implement any interfaces (except those in the base).


Public Properties

delta: number

  • The fraction of a second which passed between the last 2 updates. E.g.: 0.016

millis: number

  • The milliseconds which passed between the last 2 updates. E.g.: 16

lifetimeDelta: number

  • A compound value of all update deltas which have been calculated.

fixedDeltaTime: number

  • If set to a value more than 0, the delta time for each update will be fixed to this value.

deltaMultiplier: number

  • Can be used to scale time live. Handy for moving the game into slow / fast motion etc.
  • Available: 0.7.1+