Examining the map format

From Tiled

Jump to: navigation, search

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.

Personal tools