1681-engine / index / TextureRegistry
Class: TextureRegistry ​
Defined in: src/core/TextureRegistry.ts:104
Every texture of the world by key: the sprite atlas and per-player repainted sheets.
Constructors ​
Constructor ​
new TextureRegistry(): TextureRegistry;Returns ​
TextureRegistry
Methods ​
addAtlas() ​
addAtlas(key, pages): CanvasTexture;Defined in: src/core/TextureRegistry.ts:181
A packed atlas (TexturePacker JSON, AssetLoader.atlas): the first page under key, the others as key~1, key~2… like AtlasBuilder's pages, and every frame of every page found under key by its name.
Parameters ​
| Parameter | Type |
|---|---|
key | string |
pages | readonly object[] |
Returns ​
addCanvas() ​
addCanvas(key, canvas): CanvasTexture;Defined in: src/core/TextureRegistry.ts:159
Parameters ​
| Parameter | Type |
|---|---|
key | string |
canvas | HTMLCanvasElement |
Returns ​
addSpriteSheet() ​
addSpriteSheet(
key,
canvas,
size
): CanvasTexture;Defined in: src/core/TextureRegistry.ts:167
A canvas cut into equal frames named 0, 1, 2... left to right, then row by row.
Parameters ​
| Parameter | Type |
|---|---|
key | string |
canvas | HTMLCanvasElement |
size | { frameHeight: number; frameWidth: number; } |
size.frameHeight | number |
size.frameWidth | number |
Returns ​
addView() ​
addView(
key,
page,
x,
y,
w,
h
): CanvasTexture | null;Defined in: src/core/TextureRegistry.ts:202
Registers key as the rect (x, y, w, h) of the texture page, on the page's source: shown by setTexture(key) like any texture, and batched with every other view of that page. Null when the page is not registered.
Parameters ​
| Parameter | Type |
|---|---|
key | string |
page | string |
x | number |
y | number |
w | number |
h | number |
Returns ​
CanvasTexture | null
createCanvas() ​
createCanvas(
key,
width,
height
): CanvasTexture;Defined in: src/core/TextureRegistry.ts:211
Parameters ​
| Parameter | Type |
|---|---|
key | string |
width | number |
height | number |
Returns ​
exists() ​
exists(key): boolean;Defined in: src/core/TextureRegistry.ts:155
Parameters ​
| Parameter | Type |
|---|---|
key | string |
Returns ​
boolean
get() ​
get(key, frame?): Texture;Defined in: src/core/TextureRegistry.ts:224
Parameters ​
| Parameter | Type |
|---|---|
key | string |
frame? | string | number |
Returns ​
Texture
isLive() ​
isLive(key): boolean;Defined in: src/core/TextureRegistry.ts:115
Parameters ​
| Parameter | Type |
|---|---|
key | string |
Returns ​
boolean
markLive() ​
markLive(key): void;Defined in: src/core/TextureRegistry.ts:111
Parameters ​
| Parameter | Type |
|---|---|
key | string |
Returns ​
void
remove() ​
remove(key): void;Defined in: src/core/TextureRegistry.ts:218
Parameters ​
| Parameter | Type |
|---|---|
key | string |
Returns ​
void
snapshot() ​
snapshot(key, frame?): string;Defined in: src/core/TextureRegistry.ts:120
A new texture holding frame frame of key as it is painted right now; returns its key (one frame, '0').
Parameters ​
| Parameter | Type |
|---|---|
key | string |
frame? | string | number |
Returns ​
string
snapshotInto() ​
snapshotInto(
key,
frame,
into
): void;Defined in: src/core/TextureRegistry.ts:137
snapshot into a texture kept for reuse (into): its canvas is repainted in place and uploaded again, and only made anew when the frame's size changes. Frame '0' is the copy.
Parameters ​
| Parameter | Type |
|---|---|
key | string |
frame | string | number | undefined |
into | string |
Returns ​
void