ITimer interface
A way to track and control a timer that can be used to drive the behaviour of other components.
Signature:
export interface ITimer
Methods
Method | Description |
---|---|
getTime() | Get the timing value of the timer |
getTimeUpdates() | A more efficient way to get continuous updates of the timing value of the timer. |
pause() | Pause the timer from incrementing its time value, can be called after the timer has been started. |
reset() | Stop the timer and set it back to its original state, clearing it's time value. |
resume() | Un-pauses the timer and start incrementing the time value again, can be called after the timer has been paused. |
setSpeed(speed) | Control how quickly the timer increments. |
start() | Start the timer from its initial state or after being reset. |
stop() | Stop the timer, a call to reset is required before you can start it again. |
ITimer.getTime() method
Get the timing value of the timer
Signature:
getTime(): Promise<number>;
Returns:
Promise<number>
A promise that resolves with the amount of time the timer has been running for in milliseconds
ITimer.getTimeUpdates() method
A more efficient way to get continuous updates of the timing value of the timer.
Signature:
getTimeUpdates(): Subject<number>;
Returns:
Subject<number>
A subject triggered with the (number) value of ITimer.getTime() on every frame that it changes
ITimer.pause() method
Pause the timer from incrementing its time value, can be called after the timer has been started.
Signature:
pause(): void;
Returns:
void
ITimer.reset() method
Stop the timer and set it back to its original state, clearing it's time value.
Signature:
reset(): Promise<void>;
Returns:
Promise<void>
A promise that resolves when the operation is completed.
ITimer.resume() method
Un-pauses the timer and start incrementing the time value again, can be called after the timer has been paused.
Signature:
resume(): void;
Returns:
void
ITimer.setSpeed() method
Control how quickly the timer increments.
Signature:
setSpeed(speed: number): void;
Parameters
Parameter | Type | Description |
---|---|---|
speed | number | A fraction of the normal speed of 1 |
Returns:
void
Remarks
Note that negative values will work, but currently the ReplayPlayer doesn't handle them.
ITimer.start() method
Start the timer from its initial state or after being reset.
Signature:
start(): void;
Returns:
void
ITimer.stop() method
Stop the timer, a call to reset is required before you can start it again.
Signature:
stop(): void;
Returns:
void
Updated 7 months ago