Docs

Tileset Slicer

The Tileset Slicer tool divides a tilemap's texture into uniformly-sized tile rects. Each rect gets a name and a numeric ID — its index in the tilemap's rect list. Those IDs are the values you store in TileData cells and reference from Tilemap objects in script.

The Tileset Slicer cutting a tileset into 81 tile rects

Opening the Tileset Slicer

Select an entity with a Tilemap component. In the Properties window, click Slicer Tool in the component's Tile Rects section. The slicer cuts the tilemap's texture; when the tilemap uses several textures, pick the one to slice at the top of the dialog.

Setting up the grid

Field Purpose
Grid (Columns x Rows) / Cell Size (W x H) Slice by tile count or by tile size in pixels
Columns / Rows Number of tiles across and down; the tile size is derived from the texture size
Cell Width / Cell Height Pixel size of one tile; the number of columns and rows is derived
Offset X / Y Pixel inset of the first tile
Padding X / Y Pixel gap between tiles, for tilesets with gutters
Prefix Rect name, followed by its number: tile_0, tile_1, …

The Preview shows how many rects the grid produces, and Rect Details lists each one in pixels. Click Apply to replace the rects of the sliced texture; rects that belong to the tilemap's other textures are kept, and the new ones follow them, numbered left to right, top to bottom. The change is one undoable step.

Tile IDs

Tile IDs are plain integers. In a tilemap with a single texture, the tile at column 0, row 0 is ID 0; column 1, row 0 is ID 1; and so on. Use these IDs when filling TileData in script.

-- Create a tilemap, assign a tileset texture, and place tiles
tilemap = Tilemap(scene)
tilemap:setTexture("world/tileset.png")

-- Define texture regions (rects), then place tiles that reference them
tilemap:addRect(Rect( 0, 0, 32, 32))                 -- rect ID 0
tilemap:addRect(Rect(32, 0, 32, 32))                 -- rect ID 1

tilemap:addTile(0, Vector2( 0, 0), 32, 32)           -- rect ID, position, width, height
tilemap:addTile(1, Vector2(32, 0), 32, 32)
-- ... or paint with the rect IDs generated by the slicer directly

Painting tiles in the editor

After slicing, the TilemapComponent's Tile Rects list shows a preview of each rect. To place tiles:

  1. Select the Tilemap entity.
  2. In the Properties window, find the rect in the Tile Rects list.
  3. Drag its preview into the viewport to place a tile there.

Tile rect previews in the Tilemap component, ready to drag into the scene

When arranging placed tiles in the Scene View, enable Snap tile in the viewport gear menu so drops and gizmo moves snap to each tile's width and height — useful for packing tiles flush without tuning the global grid.

Adding collision

Tiles are only drawn, so collision comes from a 2D Physics Body on the Tilemap entity:

  1. Select the Tilemap entity and add a 2D Physics Body. Leave its type on Static.
  2. Add a Polygon shape and set its Source to Entity Tilemap.

The shape now covers the tiles with boxes. Tiles that touch are joined, first into rows and then into blocks of rows with the same width, so a flat floor is a single box and characters don't catch on the seams between tiles. The boxes are drawn in the viewport while the body is selected, and the shape's Boxes row counts them.

To leave out tiles that shouldn't block anything, like grass, clouds, or background props, click the weight button on their rect's row in the Tile Rects list. It dims when Collision is off, and every tile placed from that rect is then skipped.

Every tile becomes a full square, so a ramp tile blocks like a wall. For slopes, and for one-way platforms that need their own filter or events, turn Collision off on those rects and add a Polygon or Chain shape that follows them.

The boxes are built from the tiles each time the body loads, so tiles you paint in the editor are included the next time you play. If a script adds or removes tiles during the game, set needUpdateShapes on the body's component afterwards. See createTilemapShape.

If you want to change single boxes, for example to give a wall less friction or turn a ledge into a sensor, click Fit to Tiles in the body's Shapes section instead. It replaces the body's shapes with plain Polygon boxes over the same tiles, which you can then edit like any other shape. They don't follow later tile changes, so click Fit to Tiles again after painting. See Physics.

Tips

  • Use power-of-two tile sizes (16×16, 32×32, 64×64) for consistent UV mapping.
  • Keep the tileset image as one file even if the game uses multiple tile themes — tile ID ranges can be managed logically in data.
  • For sprite animation and character frames, use the Sprite Slicer instead.
  • Export-friendly naming: use lowercase filenames and avoid spaces so tile resource paths stay consistent across platforms.

See also