Repository navigation
API Class Tilemap
Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:136
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.
CollisionShapeSource2D
new Tilemap(): Tilemap;Tilemap
cellSize: Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:140
One cell's width and height in local units.
layers: TilemapLayerData[];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:144
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:142
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.
tileset: string = "";Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:138
The tileset asset (*.tileset.json) the cells' tile ids refer to.
variantSeed: number = 0;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:151
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:57
boolean
set enabled(value): void;Defined in: src/engine/core/Component.ts:61
boolean
void
get gameObject(): GameObject;Defined in: src/engine/core/Component.ts:37
Unity-style alias for node.
get isActiveAndEnabled(): boolean;Defined in: src/engine/core/Component.ts:68
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:312
How many layers there are.
number
get node(): GameObject;Defined in: src/engine/core/Component.ts:32
The node this component is on.
get owner(): GameObject;Defined in: src/engine/core/Component.ts:45
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:282
The tileset asset, or null while it's missing.
Tileset | null
get time(): Readonly<TimeState>;Defined in: src/engine/core/Component.ts:93
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:51
The Transform of the node this component is on, if it has one.
get world(): WorldHandle;Defined in: src/engine/core/Component.ts:82
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:487
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
cellToLocal(x, y): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:521
A cell's centre in the node's local space.
number
number
cellToWorld(x, y): Vector3;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:533
A cell's centre in world space.
number
number
clearAll(layer?): void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:425
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:368
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:411
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:339
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:334
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:353
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:347
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:358
True if the cell has a tile.
number
number
string | number = 0
boolean
instantiate(prefabPath, options?): GameObject;Defined in: src/engine/core/Component.ts:103
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:317
A layer's index by name, or -1.
string
number
localToCell(p): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:516
The cell holding a point in the node's local space.
onTileChanged(listener): () => void;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:505
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:435
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][]
retileTerrain(layer?): [number, number][];Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:447
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:374
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
setTile(
x,
y,
id,
layer?,
flags?
): boolean;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:363
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:465
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:210
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): Vector2;Defined in: src/plugins/tilemaps/runtime/Tilemap.ts:526
The cell holding a world point.
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