TiledMap class
Below is Tiled's documentation about how this structure is represented on XML files:
<map>
- version: The TMX format version. Was “1.0” so far, and will be incremented to match minor Tiled releases.
- tiledversion: The Tiled version used to save the file (since Tiled 1.0.1). May be a date (for snapshot builds). (optional)
- orientation: Map orientation. Tiled supports “orthogonal”, “isometric”, “staggered” and “hexagonal” (since 0.11).
- renderorder: 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. (only supported for orthogonal maps at the moment)
- compressionlevel: The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default).
- width: The map width in tiles.
- height: The map height in tiles.
- tilewidth: The width of a tile.
- tileheight: The height of a tile.
- hexsidelength: Only for hexagonal maps. Determines the width or height (depending on the staggered axis) of the tile’s edge, in pixels.
- staggeraxis: For staggered and hexagonal maps, determines which axis (“x” or “y”) is staggered. (since 0.11)
- staggerindex: For staggered and hexagonal maps, determines whether the “even” or “odd” indexes along the staggered axis are shifted. (since 0.11)
- backgroundcolor: The background color of the map. (optional, may include alpha value since 0.15 in the form #AARRGGBB.) Defaults to fully transparent.
- nextlayerid: 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) (defaults to the highest layer id in the file + 1)
- nextobjectid: 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) (defaults to the highest object id in the file + 1)
- infinite: Whether this map is infinite. An infinite map has no fixed size and can grow in all directions. Its layer data is stored in chunks. (0 for false, 1 for true, defaults to 0)
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 staggered orientation refers to an isometric map using staggered axes.
Can contain at most one: <properties>
Can contain any number: <tileset>
, <layer>
, <objectgroup>
,
<imagelayer>
, <group>
(since 1.0), <editorsettings>
(since 1.3)
Constructors
-
TiledMap.new({required int width, required int height, required int tileWidth, required int tileHeight, TileMapType type = TileMapType.map, String version = '1.0', String? tiledVersion, bool infinite = false, List<
Tileset> tilesets = const [], List<Layer> layers = const [], String? backgroundColorHex, ColorData? backgroundColor, int compressionLevel = -1, int? hexSideLength, int? nextLayerId, int? nextObjectId, MapOrientation? orientation, RenderOrder renderOrder = RenderOrder.rightDown, StaggerAxis? staggerAxis, StaggerIndex? staggerIndex, List<EditorSetting> editorSettings = const [], CustomProperties properties = CustomProperties.empty}) -
TiledMap.parse(Parser parser, {List<
TsxProvider> ? tsxList}) -
factory
Properties
- backgroundColor ↔ ColorData?
-
ColorData to be rendered as a solid color behind all other layers
(optional).
getter/setter pair
- backgroundColorHex ↔ String?
-
Hex-formatted color (#RRGGBB or #AARRGGBB) to be rendered as a solid color
behind all other layers (optional).
getter/setter pair
- compressionLevel ↔ int
-
getter/setter pair
-
editorSettings
↔ List<
EditorSetting> -
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- height ↔ int
-
getter/setter pair
- hexSideLength ↔ int?
-
getter/setter pair
- infinite ↔ bool
-
getter/setter pair
-
layers
↔ List<
Layer> -
getter/setter pair
- nextLayerId ↔ int?
-
getter/setter pair
- nextObjectId ↔ int?
-
getter/setter pair
- orientation ↔ MapOrientation?
-
getter/setter pair
- properties ↔ CustomProperties
-
getter/setter pair
- renderOrder ↔ RenderOrder
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- staggerAxis ↔ StaggerAxis?
-
getter/setter pair
- staggerIndex ↔ StaggerIndex?
-
getter/setter pair
- tiledVersion ↔ String?
-
getter/setter pair
- tileHeight ↔ int
-
getter/setter pair
-
tilesets
↔ List<
Tileset> -
getter/setter pair
- tileWidth ↔ int
-
getter/setter pair
- type ↔ TileMapType
-
getter/setter pair
- version ↔ String
-
getter/setter pair
- width ↔ int
-
getter/setter pair
Methods
-
collectImagesInLayer(
Layer layer) → List< TiledImage> -
layerByName(
String name) → Layer -
Finds the first layer with the matching
name
, or throw an ArgumentError if one cannot be found. Will search recursively through Group children. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
objectById(
int id) → TiledObject? -
Finds the TiledObject in this map with the unique
id
. Objects have map wide unique IDs which are never reused. https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#object -
tileByGid(
int tileGid) → Tile? -
tileByLocalId(
String tileSetName, int localId) → Tile? -
tileByPhrase(
String tilePhrase) → Tile? -
tiledImages(
) → List< TiledImage> -
tilesetByName(
String name) → Tileset -
tilesetByTileGId(
int tileGId) → Tileset -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromString(
String contents, Future< TsxProvider> tsxProviderFunction(String key)) → Future<TiledMap> -
Takes a string
contents
and converts it to a TiledMap with the help of the TsxProviders returned from thetsxProviderFunction
. ThetsxProviderFunction
is most commonly your static TsxProvider.parse implementation.