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 in your browser, on Mac and Windows, and on iPad.

On Windows, this page’s keys are pressed with Ctrl for Cmd, Alt for ⌥ and Enter for Return: hold Alt to swap two things, and Alt+Enter starts a new line. Redo is Ctrl+Y.

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:

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.

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.

Properties

A thing can carry properties, a key and a value your code reads: a chest’s content, a sign’s text, the cell a door’s key is on. Select a thing with Select: its properties are listed under Selected, in Properties. Double-click a thing to go straight to its first value.

Add Property offers the keys the other things of the same name already have, then New Property… for a key of your own: a letter first, then letters, digits and _, 32 at most. name, row and column are the thing’s own, and a thing has each key once; a refused key is said under its row.

A value has one of four types, picked in the menu at the start of its field, never guessed from what you type (Text by default):

Click a key for its menu: Rename…, its type, Remove Property. A type that can’t keep the value asks before clearing it. A thing’s properties go with it when you move, cut, copy or paste it, and things pasted together point at each other. A dot marks the things that have properties, and the status line shows the values of the thing under the pointer.

With several things selected, every key any of them has is listed once: a value they don’t share reads mixed, and a key only some of them have says how many (1 of 2), with Add to All in its menu. An edit sets it on all of them, in one Undo.

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

map.props(row, column) gives the properties of the thing on a cell, as a new dict ({} when it has none). A Thing or Cell reads as (row, column):

door = level.map.props(1, 4)
if door.get("locked", False):
    row, column = door["key_from"]   # the cell the key is on

With the level mechanic, level.props(spot) reads them at a spot: level.props(level.spot("sign"))["text"].

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.