Tiled, a generic tile map editor

Tutorial 1: Creating a simple map in Tiled

Introduction

While Tiled is meant to be easy to use, it has a learning curve like anything else. This tutorial is meant to help flatten the curve. In this tutorial we'll get you started on creating a new map, creating a tileset, editing and finally, saving.

A brave new map

Fig. 1.1
Fig. 1.1: Creating a new map

Let's begin by creating a new map from File->New. Once the New Map Dialog appears (Fig. 1.1), we will set the initial dimensions and the orientation. We will create a standard, orthogonal map as an example.

The dimensions, or size in tiles, of the map will be 32 tiles wide by 32 tiles high for our example. The dimensions of the individual tiles will be 24x24. This is the size of the tiles we will be using later, it is important to get this right when you start a new map. Click OK.

We are now presented with the main Tiled editing window (Fig. 1.2). As you can see there are no tiles and only one layer, which is selected. We now need to bring in a tileset for our map. Maps can have any number of tilesets. For us, a single internal tileset will do. From the Tilesets menu, select New tileset...

Fig. 1.2
Fig. 1.2: The main Tiled window

On internal and external tilesets

Tilesets are not necessarily tied to a specific map. In Tiled, tilesets can be independent resources, which the maps can reference. By default, when you create a tileset, it'll store it in the map. If you want to use the same tileset in multiple maps, you can export it to a .tsx file and import the tileset into other maps you create.

The tile images can be stored with the tileset as png, base64 encoded, or stored externally and referenced by the tileset.

Note: When we talk about a tileset, we mean the set as defined by the tileset element either within a map file or stored in a .tsx file, not the tileset image.

Adding a tileset

Fig. 1.3
Fig. 1.3: Creating a new tileset

Once at the New tileset window (Fig. 1.3), we will name our set to make it easier to recognize it later. We have a tileset image (pipe tiles), so we check Reference tileset image, and click Browse to find our image. Since we have no frame or grid around the tiles in the set image, we leave Tile spacing on 0. Click OK.

The final steps, drawing and saving

Now that a tileset has been added to the map, you can click the collapsed button in the bottom left and the tile palette dialog will pop-up. You can adjust the width of the palette so that the number of tiles shown vertically match the tileset image. While editing you can leave the tileset palette dialog open for easy access to your tiles.

With a tile and the pencil selected, you can start drawing tiles on your map. Also try out the fill, eraser and eye dropper tools.

Hint: While you can select the eye dropper to select a tile from the map, right clicking on the map while any tool is selected will do the same.

Finally safe your map using File->Save. Choose a name like tutorial1.tmx.

Tutorial 2: Examining the map format

In our second tutorial we shall take a look at the map format used by Tiled. Here's the what the contents look like for the file we just created:

<?xml version="1.0" ?>
<map orientation="orthogonal" width="32" height="32" tilewidth="24" tileheight="24">
  <tileset firstgid="1" name="Sewers" tilewidth="24" tileheight="24">
    <image source="tiledweb/files/tiles_pipes.png"/>
  </tileset>
  <layer name="Layer 0">
    <data encoding="base64" compression="gzip">
      H4sIAAAAAAAAAO3NoREAMAgEsLedAfafE4+s6l0jolNJiif18tt/Fj8AAMC9ARtYg28AEAAA
    </data>
  </layer>
</map>

This is an example of a minimal useful map file. Such a map file will have at least one tileset and at least one layer. Note that the information you filled in when you created the map is all stored in attributes of the map element.

The same goes for the tileset. Note that the tile spacing, which we set to 0, is not stored. This is because 0 is the default, and assumed when it's left out. Many attributes have default values.

Hint: While Tiled itself doesn't offer you a way to change the parameters you entered when creating the map yet, it is easy to change them yourself. For example when you decide to switch to a larger tile size or to rename your tileset image. This is one of the advantages of using XML.

Global tile IDs

A thing to note about the tileset is the firstgid attribute. The map layer data is an array of 32-bit integers storing global tile ids. Global means that they span the possibly multiple tilesets that the map is using. Each tileset internally uses local tile ids, and the firstgid attributes specifies how the local ids are mapped to global ids. Namely, a tile with id A in the tileset will be referred to with a number equal to firstgid+A in the layer data.

That's it for now. Keep the questions coming! Asking us questions is the best way to let us know which things are not quite understood yet and how our editor is used.