A tile map, tmxlib’s core class
init arguments, which become attributes:
- size¶
a (height, width) pair specifying the size of the map, in tiles
- tile_size¶
a pair specifying the size of one tile, in pixels
- orientation¶
The orientation of the map ('orthogonal', 'isometric', or 'staggered')
- background_color¶
The background color for the map, as a triple of floats (0..1)
- stagger_axis¶
Stagger axis for hexagonal maps (‘x’ or ‘y’, or None)
- stagger_index¶
Stagger index for hexagonal maps (‘odd’ or ‘even’, or None)
- hex_side_length¶
Side length for hexagonal maps (int, or None)
Other attributes:
- tilesets¶
A TilesetList of tilesets this map uses
- layers¶
A LayerList of layers this map uses
- properties¶
A dict of properties, with string (or unicode) keys & values
- pixel_size¶
The size of the map, in pixels. Not settable directly: use size and tile_size for that.
- end_gid¶
The first GID that is not available for tiles. This is the end_gid for the map’s last tileset.
Unpacked size attributes:
Methods:
- add_layer(name, before=None, after=None, layer_class=None)[source]¶
Add an empty layer with the given name to the map.
By default, the new layer is added at the end of the layer list. A different position may be specified with either of the before or after arguments, which may be integer indices or names.
layer_class defaults to TileLayer
- add_tile_layer(name, before=None, after=None)[source]¶
Add an empty tile layer with the given name to the map.
See add_layer
- add_object_layer(name, before=None, after=None)[source]¶
Add an empty object layer with the given name to the map.
See add_layer
Loading and saving (see tmxlib.fileio.ReadWriteBase for more information):