1681-engine / index / TilemapView
Class: TilemapView ​
Defined in: src/tilemap/TilemapView.ts:36
Draws a Tiled map's tile layers. Each layer is cut into chunks painted once into textures; a frame only toggles which chunks are in view (update), so a map of any size costs a handful of sprites a frame.
Animated tiles are drawn on their first frame.
Constructors ​
Constructor ​
new TilemapView(
stage,
map,
options?
): TilemapView;Defined in: src/tilemap/TilemapView.ts:47
Parameters ​
| Parameter | Type |
|---|---|
stage | Stage |
map | TileMap |
options | TilemapViewOptions |
Returns ​
TilemapView
Properties ​
layers ​
readonly layers: Map<string, Container<ContainerChild>>;Defined in: src/tilemap/TilemapView.ts:38
One container per drawn tile layer, by name, each at its own depth among the bodies.
map ​
readonly map: TileMap;Defined in: src/tilemap/TilemapView.ts:49
Accessors ​
heightPx ​
Get Signature ​
get heightPx(): number;Defined in: src/tilemap/TilemapView.ts:122
Returns ​
number
widthPx ​
Get Signature ​
get widthPx(): number;Defined in: src/tilemap/TilemapView.ts:118
World size of the map in px.
Returns ​
number
Methods ​
destroy() ​
destroy(): void;Defined in: src/tilemap/TilemapView.ts:126
Returns ​
void
refreshTiles() ​
refreshTiles(layerName, cells): void;Defined in: src/tilemap/TilemapView.ts:94
Repaints the chunks holding these cells (row-major indices) of a drawn layer, after its data changed: a door opening, a wall dug out, a cell autotiled again (updateAutotile returns exactly the indices to pass). Costs one chunk's painting per chunk touched, so keep it out of every frame.
Parameters ​
| Parameter | Type |
|---|---|
layerName | string |
cells | Iterable<number> |
Returns ​
void
update() ​
update(margin?): void;Defined in: src/tilemap/TilemapView.ts:82
Shows only the chunks in the camera's view (plus a margin in world px). Call once a frame.
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
margin | number | 32 |
Returns ​
void