1681-engine / index / FloatingText
Class: FloatingText ​
Defined in: src/fx/FloatingText.ts:52
Floating text — damage numbers, pickups, "+1" — drawn from bitmap fonts and reused rather than created and destroyed each time: a crowded fight throws dozens a second, and as canvas text each one repainted a canvas at resolution 4 and uploaded it. A label keeps its font, so spent ones are pooled per style and only their string changes. Fonts are baked ahead (warm): a style first met mid-fight baked its glyph pages on that frame.
Constructors ​
Constructor ​
new FloatingText(stage, options): FloatingText;Defined in: src/fx/FloatingText.ts:59
Parameters ​
| Parameter | Type |
|---|---|
stage | Stage |
options | FloatingTextOptions |
Returns ​
FloatingText
Methods ​
clear() ​
clear(): void;Defined in: src/fx/FloatingText.ts:150
Destroys every pooled label (a scene ending); labels still out are the scene's to free.
Returns ​
void
float() ​
float(
x,
y,
text,
style,
options?
): BitmapLabel;Defined in: src/fx/FloatingText.ts:128
A label that pops, rises, fades and goes back to the pool by itself, on the stage's own tweens.
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
text | string |
style | FloatingTextStyle |
options | FloatOptions |
Returns ​
install() ​
install(style): void;Defined in: src/fx/FloatingText.ts:87
Bakes one style's font now.
Parameters ​
| Parameter | Type |
|---|---|
style | FloatingTextStyle |
Returns ​
void
release() ​
release(t, style): void;Defined in: src/fx/FloatingText.ts:114
Hands a finished label back for reuse.
Parameters ​
| Parameter | Type |
|---|---|
t | BitmapLabel |
style | FloatingTextStyle |
Returns ​
void
take() ​
take(
x,
y,
text,
style
): BitmapLabel;Defined in: src/fx/FloatingText.ts:92
A label ready to animate: shown, opaque, unscaled, anchored at its bottom centre on (x, y).
Parameters ​
| Parameter | Type |
|---|---|
x | number |
y | number |
text | string |
style | FloatingTextStyle |
Returns ​
warm() ​
warm(
styles,
delayMs?,
gapMs?
): () => void;Defined in: src/fx/FloatingText.ts:73
Bakes the fonts of styles, one a task starting delayMs from now, so no frame pays for them all at once — ten at once froze a world's first frame half a second (each font measures and kerns every glyph). Returns a cancel.
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
styles | readonly FloatingTextStyle[] | undefined |
delayMs | number | 1000 |
gapMs | number | 50 |
Returns ​
() => void