Skip to content

GameTimer

Overview

Game timer, keeps track of the elapsed time in the game using "wall clock" time. The frame rate of this clock is sufficient for displaying a game timer in "seconds", but not for driving smooth animation.

@author Chris Malley (PixelZoom, Inc.)

Class GameTimer

import { GameTimer } from 'scenerystack/vegas';

Constructor

new GameTimer()

Instance Methods

reset()

start()

Starts the timer. This is a no-op if the timer is already running.

stop()

Stops the timer. This is a no-op if the timer is already stopped.

restart()

Convenience function for restarting the timer.

Instance Properties

isRunningProperty : Property<boolean>

(readonly)

whether the timer is running

elapsedTimeProperty : Property<number>

(readonly)

seconds since the timer was started

Static Methods

formatTime( time : number ) : string

Formats a value representing seconds into H:MM:SS (localized).

Source Code

See the source for GameTimer.ts in the vegas repository.