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#
| Parameter | Type |
|---|---|
options | OdometerOptions |
Returns#
Odometer
Overrides#
Container.constructor
Properties#
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
state | readonly | OdometerState | Signals to read and write. See OdometerState. | ui/odometer.ts:113 |
Methods#
destroy()#
destroy(options?: DestroyOptions): void;
Stops the count. Destroys children by default.
Parameters#
| Parameter | Type |
|---|---|
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#
| Parameter | Type |
|---|---|
value | number |
Returns#
string
set()#
set(value: number): void;
Counts to value. Same as writing state.value.
Parameters#
| Parameter | Type |
|---|---|
value | number |
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#
| Parameter | Type |
|---|---|
dt | number |
Returns#
boolean