Skip to content

1681-engine / index / BitmapLabel

Class: BitmapLabel ​

Defined in: src/core/BitmapLabel.ts:65

Text drawn from a bitmap font: the glyphs are rasterised once per font, so changing the string costs no canvas redraw and no texture upload, and every label of one font batches with the others. For the floating numbers, which a crowded fight throws dozens of a second — a plain Text repaints its canvas at resolution 4 and uploads it on every change.

Extends ​

  • BitmapText<this> & GameObjectMembers<this>

Constructors ​

Constructor ​

ts
new BitmapLabel(
   x, 
   y, 
   text, 
   fontFamily, 
   size, 
   color, 
   stroke, 
   strokeWidth, 
   resolution, 
   glyphs?
): BitmapLabel;

Defined in: src/core/BitmapLabel.ts:71

fontFamily must already be loaded (document.fonts.load), or the glyphs bake in the fallback. Styled like worldText: the same font, size, colour and outline, rasterised at the same resolution. glyphs: letters beyond ASCII it prints (see installLabelFont).

Parameters ​

ParameterTypeDefault value
xnumberundefined
ynumberundefined
textstringundefined
fontFamilystringundefined
sizenumberundefined
colorstringundefined
strokestringundefined
strokeWidthnumberundefined
resolutionnumberundefined
glyphsstring''

Returns ​

BitmapLabel

Overrides ​

ts
GameObject(BitmapText).constructor

Properties ​

active ​

ts
readonly active: boolean;

Defined in: src/core/gameObject.ts:42

False once destroyed.

Inherited from ​

ts
GameObject(BitmapText).active

depth ​

ts
depth: number;

Defined in: src/core/gameObject.ts:44

The draw order in the world layer (zIndex): bigger is in front.

Inherited from ​

ts
GameObject(BitmapText).depth

flipX ​

ts
flipX: boolean;

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

Inherited from ​

ts
GameObject(BitmapText).flipX

flipY ​

ts
flipY: boolean;

Defined in: src/core/gameObject.ts:49

Inherited from ​

ts
GameObject(BitmapText).flipY

scaleX ​

ts
scaleX: number;

Defined in: src/core/gameObject.ts:46

Scale without the flip: stays positive on a mirrored sprite.

Inherited from ​

ts
GameObject(BitmapText).scaleX

scaleY ​

ts
scaleY: number;

Defined in: src/core/gameObject.ts:47

Inherited from ​

ts
GameObject(BitmapText).scaleY

scene ​

ts
scene: Stage;

Defined in: src/core/gameObject.ts:40

Inherited from ​

ts
GameObject(BitmapText).scene

Methods ​

clearTint() ​

ts
clearTint(): this;

Defined in: src/core/gameObject.ts:64

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).clearTint

destroy() ​

Call Signature ​

ts
destroy(options?): void;

Defined in: node_modules/pixi.js/lib/scene/text/AbstractText.d.ts:481

Destroys this text renderable and optionally its style texture.

Parameters ​
ParameterTypeDescription
options?DestroyOptionsOptions parameter. A boolean will act as if all options have been set to that value
Returns ​

void

Example ​
ts
// Destroys the text and its style
text.destroy({ style: true, texture: true, textureSource: true });
text.destroy(true);
text.destroy() // Destroys the text, but not its style
Inherited from ​
ts
GameObject(BitmapText).destroy

Call Signature ​

ts
destroy(): void;

Defined in: src/core/gameObject.ts:67

Returns ​

void

Inherited from ​
ts
GameObject(BitmapText).destroy

setAlpha() ​

ts
setAlpha(a?): this;

Defined in: src/core/gameObject.ts:55

Parameters ​

ParameterType
a?number

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setAlpha

setAngle() ​

ts
setAngle(a?): this;

Defined in: src/core/gameObject.ts:59

Parameters ​

ParameterType
a?number

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setAngle

setBlendMode() ​

ts
setBlendMode(mode): this;

Defined in: src/core/gameObject.ts:60

Parameters ​

ParameterType
modeBLEND_MODES

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setBlendMode

setDepth() ​

ts
setDepth(d): this;

Defined in: src/core/gameObject.ts:54

Parameters ​

ParameterType
dnumber

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setDepth

setFlip() ​

ts
setFlip(x, y): this;

Defined in: src/core/gameObject.ts:53

Parameters ​

ParameterType
xboolean
yboolean

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setFlip

setFlipX() ​

ts
setFlipX(v): this;

Defined in: src/core/gameObject.ts:51

Parameters ​

ParameterType
vboolean

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setFlipX

setFlipY() ​

ts
setFlipY(v): this;

Defined in: src/core/gameObject.ts:52

Parameters ​

ParameterType
vboolean

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setFlipY

setOrigin() ​

ts
setOrigin(x?, y?): this;

Defined in: src/core/BitmapLabel.ts:77

Parameters ​

ParameterTypeDefault value
xnumber0.5
ynumberx

Returns ​

this


setPosition() ​

ts
setPosition(x?, y?): this;

Defined in: src/core/gameObject.ts:57

Parameters ​

ParameterType
x?number
y?number

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setPosition

setRotation() ​

ts
setRotation(r?): this;

Defined in: src/core/gameObject.ts:58

Parameters ​

ParameterType
r?number

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setRotation

setScale() ​

ts
setScale(x, y?): this;

Defined in: src/core/gameObject.ts:50

Parameters ​

ParameterType
xnumber
y?number

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setScale

setScrollFactor() ​

ts
setScrollFactor(f): this;

Defined in: src/core/gameObject.ts:66

0 pins the object to the screen instead of the world.

Parameters ​

ParameterType
fnumber

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setScrollFactor

setText() ​

ts
setText(text): this;

Defined in: src/core/BitmapLabel.ts:82

Parameters ​

ParameterType
textstring

Returns ​

this


setTint() ​

ts
setTint(color?): this;

Defined in: src/core/gameObject.ts:61

Parameters ​

ParameterType
color?number

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setTint

setTintFill() ​

ts
setTintFill(color): this;

Defined in: src/core/gameObject.ts:63

Paints every opaque pixel in one solid colour (hit flash, silhouettes).

Parameters ​

ParameterType
colornumber

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setTintFill

setVisible() ​

ts
setVisible(v): this;

Defined in: src/core/gameObject.ts:56

Parameters ​

ParameterType
vboolean

Returns ​

this

Inherited from ​

ts
GameObject(BitmapText).setVisible

Released under the MIT License.