tilemap component
A grid of tiles from one tileset asset, centred on the node. cells holds rows of tile ids; pixels_per_unit is tile pixels per world unit.
2d · render · 18 properties · 2D
A grid of tiles from one tileset asset, centred on the node. cells holds rows of tile ids; pixels_per_unit is tile pixels per world unit.
In a scene, tilemap is the node key that applies it. A script reaches each property below as a field on node.tilemap: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.tilemap.get() and node.tilemap.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
blend_mode |
enum | auto |
How the surface lands on what is under it: straight alpha, a colour that already carries its alpha, added light, multiplied shade, screen, or opaque. auto is premultiplied for a texture uploaded with premultiply, else alpha One of auto, alpha, premultiplied, add, multiply, screen, opaque. |
cells |
string | — | Rows of tile ids, -1 for an empty cell, as a list of rows; or the name of a .cells file holding those rows, for a level too big to read in a scene |
color |
color | [1,1,1,1] |
Tint over every tile, as channel floats or #rrggbb / #rrggbbaa |
cull_back_faces |
bool | false |
Skip a triangle whose back faces the viewer, as a negative scale turns one |
dot_color |
color | [1,1,1,1] |
The dots' colour |
dot_size |
float | 0 |
Size of a dot drawn on every vertex; zero draws none At least 0. |
dot_sizing |
enum | world |
What dot_size counts: world is world units, which the camera's zoom scales, screen is pixels One of world, screen. |
draw_surface |
bool | true |
Whether the surface draws; off leaves the wireframe and the dots alone |
flags |
string | — | How each cell is turned, as rows of numbers beside cells: 1 mirrors it left to right, 2 top to bottom, 4 across its diagonal |
material |
asset · material |
— | The material the whole map draws with; empty draws with the built-in one |
origin |
vec2 | [0,0] |
The column and row of the first cell: a map grows in any direction by moving this, and cell 0,0 always has its top-left corner on the node |
pixels_per_unit |
float | 100 |
Tile-texture pixels per world unit At least 0.01. |
seed |
int | 0 |
Which way the variation falls where a rule offers alternates; the same seed lays a map out the same way every time At least 0. |
terrain |
string | — | What was painted, as rows of terrain values, when the map autotiles: the cells are resolved from this through the tileset's rules |
tileset |
asset · tileset |
— | The tileset naming the texture and tile grid |
wireframe_color |
color | [1,1,1,1] |
The wireframe's colour |
wireframe_sizing |
enum | world |
What wireframe_width counts: world is world units, which the camera's zoom scales, screen is pixels One of world, screen. |
wireframe_width |
float | 0 |
Width of a line drawn along every triangle edge, not the outline; zero draws none At least 0. |
Asset types this component references: material, tileset.
Script functions
Methods of node.tilemap, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().
From render:
| method | what it does |
|---|---|
cell(int, int) -> int |
The tile at a column and row, or -1 for an empty cell or one past the edge. |
set_cell(int, int, int) |
Put one tile at a column and row; a tile below zero clears the cell, and a cell outside the map grows it in that direction. The mesh rebuilds on the next frame. |
set_terrain(int, int, int) |
Paint a terrain value at a column and row and let the tileset's rules pick the tiles, for that cell and the ring around it; below zero clears it. |
terrain(int, int) -> int |
The terrain value painted at a column and row, or -1 where nothing was painted. |
tile_data(int, int) -> any |
What the tileset says about the tile at a column and row -- its [tiles.<id>.data] table -- or nil where the cell is empty or the tile carries none. |