Repository navigation
API Class Tilemap
Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:142
Base class for everything attached to a node: built-in engine components and user
GameBehaviors (ADR 0007, 0009). Instances are created by the engine
(node.addBehavior(Type) or scene loading), never with new by game code.
CollisionShapeSource2DShadowShapeSource2D
new Tilemap(): Tilemap;Tilemap
animationSpeed: number = 1;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:167
ADR 0437: how fast tile animations play (0 stops them).
cellSize: Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:146
One cell's width and height in local units.
gridShape: TileGridShape = "square";Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:159
ADR 0437: the cell layout. cellSize is one cell's bounding box (a diamond's or hexagon's width and height).
hexSide: number = 0.5;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:165
ADR 0437: hexagonal grids: the flat sides' length along the stagger axis, as a fraction of cellSize on that axis.
layers: TilemapLayerData[];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:150
The layers, back to front within the same sorting layer and order. Scene data; see format.ts.
material: string = "";Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:148
A sprite material asset for every layer (ADR 0399: Sprite Lit or Sprite Unlit). Empty: Sprite Lit, lit by 2D lights when the World has any.
staggerAxis: "y" | "x" = "y";Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:161
ADR 0437: staggered and hexagonal grids: which rows ("y") or columns ("x") shift by half a cell.
staggerIndex: "odd" | "even" = "odd";Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:163
ADR 0437: staggered and hexagonal grids: whether the odd or the even rows (columns) shift.
tileset: string = "";Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:144
The tileset asset (*.tileset.json) the cells' tile ids refer to.
variantSeed: number = 0;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:157
Chooses among equally fitting variants (ADR 0400): auto-tiling's pick between terrain tiles that fit a cell alike,
and fillRect's pick among several tiles, are a hash of the cell and this seed, so the same strokes always paint
the same map. Changing it affects later painting; retileTerrain() re-picks the terrain cells already painted.
The editor's Re-roll button does both. Shown under the Tilemap's fields rather than as one.
get enabled(): boolean;Defined in: src/engine/core/Component.ts:62
boolean
set enabled(value): void;Defined in: src/engine/core/Component.ts:66
boolean
void
get gameObject(): GameObject;Defined in: src/engine/core/Component.ts:42
Unity-style alias for node.
get isActiveAndEnabled(): boolean;Defined in: src/engine/core/Component.ts:73
True when enabled, the node is active in the hierarchy, and the node is in a loaded world.
boolean
get layerCount(): number;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:485
How many layers there are.
number
get node(): GameObject;Defined in: src/engine/core/Component.ts:37
The node this component is on.
get owner(): GameObject;Defined in: src/engine/core/Component.ts:50
The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).
get tilesetAsset(): Tileset | null;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:309
The tileset asset, or null while it's missing.
Tileset | null
get time(): Readonly<TimeState>;Defined in: src/engine/core/Component.ts:98
This component's World's clock (ADR 0032): the same values as Time, but safe to read
outside the World's frame too (after an await, say).
Readonly<TimeState>
get transform(): Transform;Defined in: src/engine/core/Component.ts:56
The Transform of the node this component is on, if it has one.
get world(): WorldHandle;Defined in: src/engine/core/Component.ts:87
A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load
a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json").
Throws for a World no Engine owns.
cellBounds(layer?):
| {
maxX: number;
maxY: number;
minX: number;
minY: number;
}
| null;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:742
The smallest rectangle of cells holding every tile of a layer (or all layers), or null if empty.
string | number
| {
maxX: number;
maxY: number;
minX: number;
minY: number;
}
| null
cellNeighbours(x, y): Vector2[];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:791
A cell's neighbours (ADR 0437): 8 on square, isometric and staggered grids (N NE E SE S SW W NW of the grid's own axes, so an isometric "N" is up-left on screen), 6 on hexagonal ones (clockwise from the first side at or clockwise of north). Auto-tiling patterns name them in this order.
number
number
Vector2[]
cellOutline(x, y): Vector2[];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:796
A cell's corners in the node's local space, counter-clockwise (a square, a diamond or a hexagon).
number
number
Vector2[]
cellToLocal(x, y): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:781
A cell's centre in the node's local space.
number
number
cellToWorld(x, y): Vector3;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:808
A cell's centre in world space.
number
number
clearAll(layer?): void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:679
Remove every tile from a layer (or every layer).
string | number
void
clearTile(
x,
y,
layer?
): boolean;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:604
Empty a cell.
number
number
string | number = 0
boolean
fillRect(
x,
y,
width,
height,
id,
layer?
): void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:647
Fill a rectangle of cells with tile id (0 clears). With several ids, each cell picks one by the tiles' weights,
the pick drawn from the cell and variantSeed (ADR 0400), so the same call fills the same way; change the seed
for another arrangement.
number
number
number
number
number | readonly number[]
string | number = 0
void
getCell(
x,
y,
layer?
): number;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:575
The cell's raw value: tile id plus flip flags (FLIP_X, FLIP_Y, FLIP_DIAGONAL).
number
number
string | number = 0
number
getTile(
x,
y,
layer?
): number;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:570
The tile id at a cell (0 when empty or the layer doesn't exist).
number
number
string | number = 0
number
getTileData<T>(
x,
y,
layer?
): T | undefined;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:589
The custom data of the tile at a cell (from the tileset), or undefined.
T = Record<string, unknown>
number
number
string | number = 0
T | undefined
getTileDef(
x,
y,
layer?
): Readonly<TileDef> | undefined;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:583
The tileset's definition of the tile at a cell.
number
number
string | number = 0
Readonly<TileDef> | undefined
hasTile(
x,
y,
layer?
): boolean;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:594
True if the cell has a tile.
number
number
string | number = 0
boolean
instantiate(prefabPath, options?): GameObject;Defined in: src/engine/core/Component.ts:108
Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate.
Use it in code that may run after an await: by then the frame is over and the current World
is the Engine's default one, which may not be this component's. A parent from another
World throws.
string
InstantiateOptions = {}
layerIndex(name): number;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:490
A layer's index by name, or -1.
string
number
layerOffset(layer): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:511
ADR 0441: how far a layer's drawing and collision are shifted, in local units ((0, 0) for a missing layer).
string | number
layerParallax(layer): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:533
ADR 0441: how much a layer moves with the view camera, per axis ((1, 1) moves with the map; for a missing layer too).
string | number
localToCell(p, layer?): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:774
The cell holding a point in the node's local space (on any grid shape). With layer, the cell of that layer drawn
there: its offset (ADR 0441) is taken off first (parallax is visual only and ignored).
string | number
onTileChanged(listener): () => void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:760
Call listener for every changed cell (script edits); returns a function that stops it.
(change) => void
() => void
paintTerrain(
cells,
terrain,
layer?
): [number, number][];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:689
Paint a terrain into cells and re-pick the terrain tiles around them to fit (auto-tiling), or
erase the terrain with terrain null. Returns the cells that changed.
readonly (readonly [number, number])[]
string | null
string | number = 0
[number, number][]
replaceTile(
fromId,
toId,
layer?
): number;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:665
Replace every cell of tile fromId with tile toId (0 clears them), keeping each cell's flip flags, in one layer
or every layer (ADR 0442). Returns how many cells changed. Changes are reported like other script edits
(TilemapChanges, onTileChanged). Throws for a missing layer or a toId the tileset doesn't have.
number
number
string | number
number
retileTerrain(layer?): [number, number][];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:701
Re-pick every terrain cell of a layer (or every layer) for its neighbours, with variantSeed choosing among
equally fitting variants (ADR 0400): after changing the seed, to re-roll the variants, or after the tileset's
terrain tiles changed. Cells of tiles without a terrain are left alone. Returns the cells that changed (of every
layer re-tiled).
string | number
[number, number][]
setCell(
x,
y,
value,
layer?
): boolean;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:610
Set a cell's raw value (tile id plus flip flags). Returns whether the cell changed. Throws for a missing layer, a coordinate that isn't a finite number, or a tile id the tileset doesn't have.
number
number
number
string | number = 0
boolean
setLayerOffset(
layer,
x,
y
): void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:521
ADR 0441: shift a layer's drawing and collision by (x, y) local units. Cells keep their coordinates (worldToCell
with the layer reads them under the offset). Changes the runtime layer only, like other script edits
(toLayerData() writes it). Throws for a missing layer or a value that isn't finite.
string | number
number
number
void
setLayerParallax(
layer,
x,
y
): void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:543
ADR 0441: a layer's parallax factor (Tiled's): 1 moves with the map, 0 stays with the view camera, 0.5 scrolls at
half speed. Visual only: collision and worldToCell ignore it. Changes the runtime layer only, like other script
edits. Throws for a missing layer or a value that isn't finite.
string | number
number
number
void
setTile(
x,
y,
id,
layer?,
flags?
): boolean;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:599
Put tile id (0 clears) in a cell, with optional flip flags. Returns whether the cell changed.
number
number
number
string | number = 0
number = 0
boolean
tiles(layer?): Generator<{
flags: number;
id: number;
value: number;
x: number;
y: number;
}>;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:720
Every non-empty cell of a layer (a cell whose tile the tileset no longer has reads as empty).
string | number = 0
Generator<{
flags: number;
id: number;
value: number;
x: number;
y: number;
}>
toLayerData(): TilemapLayerData[];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:237
The layers' current cells as scene data (what the layers field would hold to reproduce them): each layer's
cells as its tile numbers, and its palette with the numbers its cells use (unused entries pruned).
worldToCell(p, layer?): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:801
The cell holding a world point. With layer, the cell of that layer drawn there, under its offset (ADR 0441).
string | number
This wiki is generated from docs/wiki/ and the myco module's source on every push to master. Change pages there in a pull request: edits made here are not kept.
Basics
Gameplay
Rendering
Audio
- Playing sound
- Why is there no sound?
- Playlists
- Interactive music
- Sound generators
- Spatial audio
- Audio mixer
- Live mixing
- Loudness
- Audio profiler
- Audio takes
Reference