title: Defold tile map manual
A Tile Map is a component that allows you to assemble, or paint, tiles from a Tile Source onto a large grid area. Tile maps are commonly used to build game level environments. You can also use the Collision Shapes from the tile source in your maps for collision detection and physics simulation.
Before you can create a tile map you need to create a Tile Source. Refer to the Tile Source manual to learn how to create a Tile Source.
To create a new tile map:
{srcset="images/tilemap/[email protected] 2x"}
To paint tiles on your tile map:
{srcset="images/tilemap/[email protected] 2x"}
{srcset="images/tilemap/[email protected] 2x"}
You can pick tiles directly from a layer and use the selection as a brush. Hold Shift and click a tile to pick it up as the current brush. While holding Shift you can also click and drag to select a block of tiles to use as a larger brush.
{srcset="images/tilemap/[email protected] 2x"}
To add a tile map to your game:
{srcset="images/tilemap/[email protected] 2x"}
You can read and write the content of a tile map dynamically while your game is running. To do so, use the tilemap.get_tile() and tilemap.set_tile() functions:
local tile = tilemap.get_tile("/level#map", "ground", x, y)
if tile == 2 then
-- Replace grass-tile (2) with dangerous hole tile (number 4).
tilemap.set_tile("/level#map", "ground", x, y, 4)
end