Skip to content

1681-engine / index / Clock

Class: Clock ​

Defined in: src/core/Clock.ts:23

Scene time and one-shot timers, advanced by the frame loop.

update allocates nothing (runDue): a game scheduling effect beats every few milliseconds made two filtered arrays a frame. A timer that throws is reported to onError and dropped, and the others due that frame still run.

Constructors ​

Constructor ​

ts
new Clock(): Clock;

Returns ​

Clock

Properties ​

now ​

ts
now: number;

Defined in: src/core/Clock.ts:24


onError ​

ts
onError: (err) => void;

Defined in: src/core/Clock.ts:26

Told of every error a timer throws (default: logged). Stage routes it into its guarded-step reporting.

Parameters ​

ParameterType
errunknown

Returns ​

void

Accessors ​

pending ​

Get Signature ​

ts
get pending(): number;

Defined in: src/core/Clock.ts:39

Timers waiting to run (removed ones not yet swept included).

Returns ​

number

Methods ​

clear() ​

ts
clear(): void;

Defined in: src/core/Clock.ts:48

Returns ​

void


delayedCall() ​

ts
delayedCall(ms, fn): object;

Defined in: src/core/Clock.ts:32

Parameters ​

ParameterType
msnumber
fn() => void

Returns ​

object

remove ​
ts
remove: () => void;
Returns ​

void


update() ​

ts
update(now): void;

Defined in: src/core/Clock.ts:43

Parameters ​

ParameterType
nownumber

Returns ​

void

Released under the MIT License.