Map#

This module provides the primary TiledMap class which represents a single map from Tiled.

TiledMap#

class pytiled_parser.tiled_map.TiledMap(infinite: bool, layers: List[Layer], map_size: Size, next_layer_id: Optional[int], next_object_id: int, orientation: str, render_order: str, tiled_version: str, tile_size: Size, tilesets: Dict[int, Tileset], version: str, parallax_origin: OrderedPair = OrderedPair(x=0, y=0), map_file: Optional[Path] = None, class_: Optional[str] = None, background_color: Optional[Color] = None, properties: Optional[Dict[str, Union[float, Path, str, bool, Color]]] = None, hex_side_length: Optional[int] = None, stagger_axis: Optional[str] = None, stagger_index: Optional[str] = None)#

Object for storing a Tiled map with all associated objects.

This object is the top level object for a map. It contains all layers within a map, as well as all Tiesets used by the map. When creating an implementation, this will be the primary class to work with to pull all data relating to a map.

TMX Reference

JSON Reference

infinite#

If the map is infinite or not.

Type:

bool

layers#

List of layer objects by draw order.

Type:

List[pytiled_parser.layer.Layer]

map_size#

The map width in tiles.

Type:

pytiled_parser.common_types.Size

next_layer_id#

Stores the next available ID for new layers.

Type:

Optional[int]

next_object_id#

Stores the next available ID for new objects.

Type:

int

orientation#

Map orientation. Tiled supports “orthogonal”, “isometric”, “staggered” and “hexagonal”

Type:

str

render_order#

The order in which tiles on tile layers are rendered. Valid values are right-down, right-up, left-down and left-up. In all cases, the map is drawn row-by-row. (only supported for orthogonal maps at the moment)

Type:

str

tiled_version#

The Tiled version used to save the file. May be a date (for snapshot builds).

Type:

str

tile_size#

The size of a tile.

Type:

pytiled_parser.common_types.Size

tilesets#

Dict of Tileset where Key is the firstgid and the value is the Tileset

Type:

Dict[int, pytiled_parser.tileset.Tileset]

version#

The JSON format version.

Type:

str

background_color#

The background color of the map.

Type:

Optional[pytiled_parser.common_types.Color]

properties#

The properties of the Map.

Type:

Optional[Dict[str, Union[float, pathlib.Path, str, bool, pytiled_parser.common_types.Color]]]

hex_side_length#

Only for hexagonal maps. Determines the width or height (depending on the staggered axis) of the tile’s edge, in pixels.

Type:

Optional[int]

stagger_axis#

For staggered and hexagonal maps, determines which axis (“x” or “y”) is staggered.

Type:

Optional[str]

stagger_index#

For staggered and hexagonal maps, determines whether the “even” or “odd” indexes along the staggered axis are shifted.

Type:

Optional[str]

class_#

The Tiled class of this Map.

Type:

Optional[str]

parallax_origin#

The point on the map to center the parallax scrolling of layers on.

Type:

pytiled_parser.common_types.OrderedPair