ProfilerTimer

View source

ExtendsTimer

Stores mutable time and cycle state for an application timer.

Each update advances the timer while it is active, and its cycle behavior determines whether time stops at the end of the first cycle or wraps into subsequent cycles. Pausing preserves the current position; restarting begins again from zero.

Examples

import { Timer, TimerMode } from '@wimaengine/time'

const timer = new Timer({ duration: 2, mode: TimerMode.Once })

timer.update(0.5)
timer.pause()
timer.play()
timer.update(1.5)

if (timer.completed()) {
  console.log('timer finished')
}

Constructor


constructor(options?: TimerOptions)

View source

Creates a timer with an optional duration, mode, speed, and paused state.

Parameters

NameDescriptionDefault
options?—{}