Instances of this class generate a timestamp that correlates with the time elapsed since the start of the program but allows for resetting and scaling.
Supports Timers similar to window.setInterval but with respect to the scaled time. All time values are given in milliseconds

Authors

Jirka Dell'Oro-Friedl, HFU, 2019

Hierarchy (view full)

Constructors

Properties

game: Time = ...

Standard game time starting automatically with the application

Methods

  • Stops and deletes all Timers attached. Should be called before this Time-object leaves scope

    Returns void

  • Returns a Promise to be resolved after the time given. To be used with async/await

    Parameters

    • _lapse: number

    Returns Promise<void>

  • Deletes the timer with the id given by this time object

    Parameters

    • _id: number

    Returns void

  • Deletes Timer found using the internal id of the connected interval-object

    Parameters

    • _id: number

    Returns void

  • Retrieves the current scaled timestamp of this instance in milliseconds

    Returns number

  • Retrieves the scaled time in milliseconds passed since the last call to this method Automatically reset at every call to set(...) and setScale(...)

    Returns number

  • Returns the remaining time to the given point of time

    Parameters

    • _to: number

    Returns number

  • (Re-) Sets the timestamp of this instance

    Parameters

    • _time: number = 0

      The timestamp to represent the current time (default 0.0)

    Returns void

  • Sets the scaling of this time, allowing for slowmotion (<1) or fastforward (>1)

    Parameters

    • _scale: number = 1.0

      The desired scaling (default 1.0)

    Returns void

  • Installs a timer at this time object

    Parameters

    • _lapse: number

      The object-time to elapse between the calls to _callback

    • _count: number

      The number of calls desired, 0 = Infinite

    • _handler: TimerHandler

      The function to call each the given lapse has elapsed

    • Rest ..._arguments: Object[]

      Additional parameters to pass to callback function

    Returns number