The TMX (Tile Map XML) map format used by
[Tiled](http://www.mapeditor.org) is a flexible way to describe a
tile based map. It can describe maps with any tile size, any amount
of layers, any number of tile sets and it allows custom properties
to be set on most elements. Beside tile layers, it can also contain
groups of objects that can be placed freely.
Contains a list of animation frames.
As of Tiled 0.10, each tile can have exactly one animation
associated with it. In the future, there could be support for
multiple named animations on a tile.
This is currently added only for infinite maps. The contents of a
chunk element is same as that of the data element, except it
stores the 'data' of the area specified in the attributes.
The x coordinate of the chunk in tiles.
The y coordinate of the chunk in tiles.
The width of the chunk in tiles.
The height of the chunk in tiles.
When no encoding or compression is given, the tiles are stored
as individual XML `tile` elements. Next to that, the easiest
format to parse is the "csv" (comma separated values) format.
The base64-encoded and optionally compressed layer data is
somewhat more complicated to parse. First you need to
base64-decode it, then you may need to decompress it. Now you
have an array of bytes, which should be interpreted as an array
of unsigned 32-bit integers using little-endian byte ordering.
Whatever format you choose for your layer data, you will always
end up with so called "global tile IDs" (gids). They are global,
since they may refer to a tile from any of the tilesets used by
the map. In order to find out from which tileset the tile is you
need to find the tileset with the highest `firstgid` that is
still lower or equal than the gid. The tilesets are always
stored with increasing `firstgid`s.
The encoding used to encode the tile layer data.
When used, it can be "base64" and "csv" at the
moment.
The compression used to compress the tile layer
data. Tiled Qt supports "gzip" and "zlib".
Used to mark an object as an ellipse. The existing `x`, `y`,
`width` and `height` attributes are used to determine the size
of the ellipse.
@since 0.9
The local ID of a tile within the parent tileset.
How long (in milliseconds) this frame should be displayed
before advancing to the next frame.
This element is only used in case of isometric orientation, and
determines how tile overlays for terrain and collision
information are rendered.
Orientation of the grid for the tiles in this tileset
(orthogonal or isometric)
Width of a grid cell
Height of a grid cell
A group layer, used to organize the layers of the map in a
hierarchy. Its attributes `offsetx`, `offsety`, `opacity` and
`visible` recursively affect child layers.
Note that it is not currently possible to use Tiled to create
maps with embedded image data, even though the TMX format
supports this. It is possible to create such maps using
`libtiled` (Qt/C++) or
[tmxlib](https://pypi.python.org/pypi/tmxlib) (Python).
@since 0.9
Used for embedded images, in combination with a `data` child
element. Valid values are file extensions like `png`, `gif`,
`jpg`, `bmp`, etc.
@since 0.9
Used by some versions of Tiled Java.
@deprecated and unsupported by Tiled Qt.
The reference to the tileset image file
(Tiled supports most common image formats).
@since 0.9
Defines a specific color that is treated as transparent
(example value: "#FF00FF" for magenta). Up until Tiled 0.12,
this value is written out without a `#` but this is planned
to change.
The image width in pixels (optional, used for tile index
correction when the image changes)
The image height in pixels (optional)
A layer consisting of a single image.
Unique ID of the layer. Each layer that is added to a map gets a
unique id. Even if a layer is deleted, no layer ever gets the
same ID. Can not be changed in Tiled.
@since 1.2
The name of the layer.
The x coordinate of the layer in tiles. Defaults to 0 and
can no longer be changed in Tiled Qt.
@deprecated
The y coordinate of the layer in tiles. Defaults to 0 and
can no longer be changed in Tiled Qt.
@deprecated
The width of the layer in tiles. Traditionally required, but
as of Tiled Qt always the same as the map width.
@deprecated
The height of the layer in tiles. Traditionally required,
but as of Tiled Qt always the same as the map height.
@deprecated
The opacity of the layer as a value from 0 to 1. Defaults to
1.
Whether the layer is shown (1) or hidden (0). Defaults to 1.
Rendering offset for this layer in pixels. Defaults to 0.
@since 0.14
Rendering offset for this layer in pixels. Defaults to 0.
@since 0.14
Locking flag of the layer (used by Tiled).
The `tilewidth` and `tileheight` properties determine the
general grid size of the map. The individual tiles may have
different sizes. Larger tiles will extend at the top and right
(anchored to the bottom left).
A map contains three different kinds of layers. Tile layers were
once the only type, and are simply called layer, object layers
have the objectgroup tag and image layers use the imagelayer
tag. The order in which these layers appear is the order in
which the layers are rendered by Tiled.
The TMX format version. Was "1.0" so far, and will be
incremented to match minor Tiled releases.
The Tiled version used to save the file.
May be a date (for snapshot builds).
@since 1.0.1
Map orientation. Tiled supports "orthogonal", "isometric",
"staggered" (since 0.9) and "hexagonal" (since 0.11).
The order in which tiles on tile layers are rendered. Valid
values are `right-down` (the default), `right-up`,
`left-down` and `left-up`. In all cases, the map is drawn
row-by-row. (since 0.10, but only supported for orthogonal
maps at the moment)
The map width in tiles.
The map height in tiles.
The width of a tile.
The height of a tile.
Infinite maps give you independence from bounds of the map.
@since 1.1
Only for hexagonal maps. Determines the width or height
(depending on the staggered axis) of the tile's edge, in
pixels.
For staggered and hexagonal maps, determines which axis
("x" or "y") is staggered.
@since 0.11
For staggered and hexagonal maps, determines whether the
"even" or "odd" indexes along the staggered axis are
shifted.
@since 0.11
The background color of the map. (optional, may include
alpha value since 0.15 in the form `#AARRGGBB`)
@since 0.9
Stores the next available ID for new layers. This number is
stored to prevent reuse of the same ID after layers have been
removed.
@since 1.2
Stores the next available ID for new objects. This number
is stored to prevent reuse of the same ID after objects
have been removed.
@since 0.11
While tile layers are very suitable for anything repetitive
aligned to the tile grid, sometimes you want to annotate your
map with other information, not necessarily aligned to the grid.
Hence the objects have their coordinates and size in pixels, but
you can still easily align that to the grid when you want to.
You generally use objects to add custom information to your tile
map, such as spawn points, warps, exits, etc.
When the object has a `gid` set, then it is represented by the
image of the tile with that global ID. The image alignment
currently depends on the map orientation. In orthogonal
orientation it's aligned to the bottom-left while in isometric
it's aligned to the bottom-center.
@since 1.1
@since 0.9
@since 1.0
Unique ID of the object. Each object that is placed on a map
gets a unique id. Even if an object was deleted, no object
gets the same ID. Can not be changed in Tiled Qt.
@since 0.11
The name of the object. An arbitrary string.
The type of the object. An arbitrary string.
The x coordinate of the object in pixels.
The y coordinate of the object in pixels.
The width of the object in pixels (defaults to 0).
The height of the object in pixels (defaults to 0).
The rotation of the object in degrees clockwise (defaults to
0).
@since 0.10
An reference to a tile (optional).
Whether the object is shown (1) or hidden (0). Defaults to
1.
@since 0.9
A reference to a template file (optional).
The object group is in fact a map layer, and is hence called
"object layer" in Tiled Qt.
The color used to display the objects in this group.
Whether the objects are drawn according to the order
of appearance ("index") or sorted by their
y-coordinate ("topdown"). Defaults to "topdown".
Used to mark an object as a point.
The existing x and y attributes are used to determine the position of the point.
Each `polygon` object is made up of a space-delimited list of
x,y coordinates. The origin for these coordinates is the
location of the parent `object`. By default, the first point is
created as 0,0 denoting that the point will originate exactly
where the `object` is placed.
A list of x,y coordinates in pixels.
A `polyline` follows the same placement definition as a
`polygon` object.
A list of x,y coordinates in pixels.
Wraps any number of custom properties. Can be used as a child of
the `map`, `tileset`, `tile` (when part of a `tileset`),
`terrain`, `layer`, `objectgroup`, `object`, `imagelayer` and
`group` elements.
The name of the property.
The type of the property. Can be `string` (default), `int`,
`float`, `bool`, `color` or `file` (since 0.16, with `color`
and `file` added in 0.17).
The value of the property.
The template root element contains the saved map object and a
tileset element that points to an external tileset, if the
object is a tile object.
The name of the terrain type.
The local tile-id of the tile that represents the terrain
visually.
This element defines an array of terrain types, which can be
referenced from the `terrain` attribute of the `tile` element.
Used to mark an object as a text object. Contains the actual
text as character data.
The font family used (default: "sand-serif")
The size of the font in pixels (not using points,
because other sizes in the TMX format are also using
pixels) (default: 16)
Whether word wrapping is enabled (1) or disabled
(0). Defaults to 0.
Color of the text in `#AARRGGBB` or `#RRGGBB` format
(default: #000000)
Whether the font is bold (1) or not (0). Defaults to
0.
Whether the font is italic (1) or not (0). Defaults
to 0.
Whether a line should be drawn below the text (1) or
not (0). Defaults to 0.
Whether a line should be drawn through the text (1)
or not (0). Defaults to 0.
Whether kerning should be used while rendering the
text (1) or not (0). Default to 1.
Horizontal alignment of the text within the object
(`left` (default), `center` or `right`)
Vertical alignment of the text within the object
(`left` (default), `center` or `right`)
@since 0.9
@since 0.10
@since 0.10
The local tile ID within its tileset.
The type of the tile. Refers to an object type and is used
by tile objects. (optional)
@since 1.0
Defines the terrain type of each corner of the tile, given
as comma-separated indexes in the terrain types array in the
order top-left, top-right, bottom-left, bottom-right.
Leaving out a value means that corner has no terrain.
(optional)
@since 0.9
A percentage indicating the probability that this tile is
chosen when it competes with others while editing with the
terrain tool. (optional)
@since 0.9
All `tileset` tags shall occur before the first `layer` tag so
that parsers may rely on having the tilesets before needing to
resolve tiles.
This element is used to specify an offset in pixels, to be
applied when drawing a tile from the related tileset. When not
present, no offset is applied.
Horizontal offset in pixels
Vertical offset in pixels (positive is down)
If there are multiple `tileset` elements, they are in ascending
order of their `firstgid` attribute. The first tileset always
has a `firstgid` value of 1\. Since Tiled 0.15, image collection
tilesets do not necessarily number their tiles consecutively
since gaps can occur when removing tiles.
@since 0.8
@since 1.0
@since 0.8
@since 0.9
@since 1.1
The first global tile ID of this tileset (this global ID
maps to the first tile in this tileset).
The name of this tileset.
If this tileset is stored in an external TSX (Tile Set XML)
file, this attribute refers to that file. That TSX file has
the same structure as the element described here. (There is
the **firstgid** attribute missing and this source attribute
is also not there. These two attributes are kept in the TMX
map, since they are map specific.)
The (maximum) width of the tiles in this tileset.
The (maximum) height of the tiles in this tileset.
The spacing in pixels between the tiles in this tileset
(applies to the tileset image).
The margin around the tiles in this tileset (applies to the
tileset image).
The number of tiles in this tileset
@since 0.13
The number of tile columns in the tileset. For image
collection tilesets it is editable and is used when
displaying the tileset.
@since 0.15
A color that can be used to define the corner of a Wang tile.
The name of this color.
The color in `#RRGGBB` format (example: `#c17d11`).
The tile ID of the tile representing this color.
The relative probability that this color is chosen over
others in case of multiple options.
A color that can be used to define the edge of a Wang tile.
The name of this color.
The color in `#RRGGBB` format (example: `#c17d11`).
The tile ID of the tile representing this color.
The relative probability that this color is chosen over
others in case of multiple options.
Defines a list of corner colors and a list of edge colors, and
any number of Wang tiles using these colors.
The name of the Wang set.
The tile ID of the tile representing this Wang set.
Contains the list of Wang sets defined for this tileset.
Defines a Wang tile, by referring to a tile in the tileset and
associating it with a certain Wang ID.
The tile ID.
The Wang ID, which is a 32-bit unsigned integer stored in
the format 0xCECECECE (where each C is a corner color and
each E is an edge color, from right to left clockwise,
starting with the top edge)
@deprecated since 0.15
@since 0.9
@since 0.11
When a string property contains newlines, the current
version of Tiled will write out the value as characters
contained inside the `property` element rather than as
the `value` attribute. It is possible that a future
version of the TMX format will switch to always saving
property values inside the element rather than as an
attribute.
@since 0.16
@since 0.16
@since 0.16
Boolean properties have a value of either "true"
or "false".
@since 0.16
Color properties are stored in the format `#AARRGGBB`.
@since 0.17
File properties are stored as paths relative from
the location of the map file.
@since 0.17