Skip to content
pixi-silk
GitHub repository
Class

Odometer

import { Odometer } from 'pixi-silk/ui/odometer';

A number that rolls its digits into place like a mechanical counter, for live readouts, scores and totals. Each column shows two glyphs at most and the frame only moves them, so it stays cheap while counting. Glyphs come from a bitmap font made from the text style on first use. A mask clips the columns. The number is centred on the origin.

Negative values roll as their absolute value: the rolling display draws no minus sign. Odometer.format does include it.

Extends#

  • Container

Constructors#

Constructor#

new Odometer(options?: OdometerOptions): Odometer;

Parameters#

ParameterType
optionsOdometerOptions

Returns#

Odometer

Overrides#

Container.constructor

Properties#

PropertyModifierTypeDescriptionDefined in
statereadonlyOdometerStateSignals to read and write. See OdometerState.ui/odometer.ts:113

Methods#

destroy()#

destroy(options?: DestroyOptions): void;

Stops the count. Destroys children by default.

Parameters#

ParameterType
options?DestroyOptions

Returns#

void

Overrides#

Container.destroy

format()#

format(value: number): string;

Text of a value in this odometer’s format (sign, prefix, padding, separators, suffix), without rolling.

Parameters#

ParameterType
valuenumber

Returns#

string


set()#

set(value: number): void;

Counts to value. Same as writing state.value.

Parameters#

ParameterType
valuenumber

Returns#

void


skip()#

skip(): void;

Jumps to the end of the current count. onDone fires on the next step.

Returns#

void


tick()#

tick(dt: number): boolean;

Advances the count by dt seconds (only needed with ticker: null). Returns true while counting.

Parameters#

ParameterType
dtnumber

Returns#

boolean