Tilemap Editor
A tilemap is a level: a grid of cells painted with the tiles of one of your images, with tags your code reads, and things placed on it, a hero’s start, coins, chests. It opens in the tilemap editor on iPad and Mac.
Opening the tilemap editor
Choose a .tilemap in Files: it opens straight in the tilemap editor. To make a new one, choose File › New Asset… and pick Tilemap (see Projects & Assets).
The bar names the map and says its size, its tiles’ size and the zoom. Tiles | Things chooses the layer you edit (L). Grid shows the cells’ lines, and Map Settings links the tileset, resizes the map and sets the cell size.
Painting tiles
On the Tiles layer, the side column shows the tileset: click a tile to pick it, or drag across several to pick a stamp. The tools run down the edge of the canvas, each with its key:
- Pencil (B) — paint the picked tile or stamp
- Eraser (E) — clear cells
- Fill (G) — flood the connected cells of the same tile
- Rectangle (U) — fill a rectangle
- Eyedropper (I) — the tile under it becomes the one you paint with
- Select (M) — select cells, then move, cut, copy or paste them
Paint Tags (T) paints the tag picked under the tileset instead of tiles, and Show Tags shows them over the map. Code reads a cell’s tag with map.hit(…): tag 2 for walls, say (see Collision).
The Things layer
Things are names on cells: where the hero starts, a row of coins, a chest. Choose Things in the bar (L) to place them. The side column becomes the Things palette: every sprite of the project, drawn with its first frame, and named after it. A thing’s name is its sprite’s name, and it is what your code reads.
- Place (B) — puts the sprite picked in the palette in the cell. Drag to place one in each cell you cross. A cell holds one thing: placing on a cell that holds one replaces it.
- Remove (E) — removes the thing under it; drag to remove each one you cross.
- Pick (I) — the thing’s name becomes the one you place.
- Select (M) — click a thing to select it, ⇧-click to add one, or drag from an empty cell to select the things in a rectangle. Drag a selected thing to move it; several keep their spacing. The arrow keys move a selection a cell.
A thing never lands on another: a move onto a cell that holds one is refused, the thing goes back and the editor says what holds the cell. Hold ⌥ to swap the two. Delete, Cut, Copy and Paste work on things (a pasted group follows the pointer until you click). Show Names (N) shows every name; otherwise a name shows when you select or point at its thing. Fill, Rectangle and Paint Tags are dimmed on the Things layer.
On the Tiles layer, things stay on the map at 40 %, and a click paints the tile under one, never the thing.
On this map counts the things of each name; click a name to select them all. Right-click the map for the layer’s menu.
Kinds
New Kind…, in the palette, gives a sprite’s frame its own name: a guard drawn with the slime sprite’s second frame, beside the slime. A kind is saved with the map, and listed in the palette after the sprites.
Renaming a sprite in Files asks Rename its 3 things too? when things on the project’s maps are drawn with it: Rename Things renames them on every map, with the kinds drawn with it, and one Undo takes back the new name and the things together; Keep Their Names leaves them. A thing whose sprite was deleted, or renamed without it, keeps its name, drawn as a dashed placeholder until a sprite or a kind has that name again.
On iPad
A tap places a thing where your finger lifts. With Select, drag a thing to move it; whatever the tool, a long press lifts a thing so you can move it, or shows its menu when you let go without moving. The edit capsule over the map has Delete on the Things layer. Two fingers pan and zoom, and never place anything.
In code
map.things() lists the things as (name, row, column):
level = world.spawn(map=GridMap(tilemap="level"))
for name, row, column in level.map.things():
if name == "coin":
place_coin(row, column) # your game's own function
See GridMap for the format and the rest of the map’s functions.
Used in Code in the pane’s bar lists the lines of your scripts that name this map; choose one to go to it. In the code, Cmd+Click the map’s name to come back here.
Undo and redo
Every edit is one step of Undo (Cmd+Z): a stroke of tiles, a drag that places a row of coins, a move of several things.