Phaser API Documentation

  Version: 
Filter
Namespace: Tiled
Phaser.Tilemaps.Parsers.Tiled

Methods

<static> AssignTileProperties(mapData)
Focus
Focus

Description:

Copy properties from tileset to tiles.

Parameters:

name type description
mapData Phaser.Tilemaps.MapData

The Map Data object.

Focus
Focus
<static> Base64Decode(data)
Focus
Focus

Description:

Decode base-64 encoded data, for example as exported by Tiled.

Parameters:

name type description
data object

Base-64 encoded data to decode.

Returns:
Description:

Array containing the decoded bytes.

Type:
  • array
Since: 3.0.0
Focus
Focus
<static> BuildTilesetIndex(mapData)
Focus
Focus

Description:

Master list of tiles -> x, y, index in tileset.

Parameters:

name type description
mapData Phaser.Tilemaps.MapData

The Map Data object.

Returns:
Description:

An array of Tileset objects.

Type:
  • array
Focus
Focus
<static> CreateGroupLayer(json, [group], [parentState])
Focus
Focus

Description:

Parse a Tiled group layer and create a state object for inheriting.

Parameters:

name type arguments description
json object

The Tiled JSON object.

group object <optional>

The current group layer from the Tiled JSON file.

parentState object <optional>

The state of the parent group (if any).

Returns:
Description:

A group state object with proper values for updating children layers.

Type:
  • object
Since: 3.21.0
Focus
Focus
<static> ParseGID(gid)
Focus
Focus

Description:

See Tiled documentation on tile flipping: http://docs.mapeditor.org/en/latest/reference/tmx-map-format/

Parameters:

name type description
gid number

A Tiled GID.

Returns:
Description:

The GID Data.

Since: 3.0.0
Focus
Focus
<static> ParseImageLayers(json)
Focus
Focus

Description:

Parses a Tiled JSON object into an array of objects with details about the image layers.

Parameters:

name type description
json object

The Tiled JSON object.

Returns:
Description:

Array of objects that include critical info about the map's image layers

Type:
  • array
Focus
Focus
<static> ParseJSONTiled(name, source, insertNull)
Focus
Focus

Description:

Parses a Tiled JSON object into a new MapData object.

Parameters:

name type description
name string

The name of the tilemap, used to set the name on the MapData.

source object

The original Tiled JSON object. This is deep copied by this function.

insertNull boolean

Controls how empty tiles, tiles with an index of -1, in the map data are handled. If true, empty locations will get a value of null. If false, empty location will get a Tile object with an index of -1. If you've a large sparsely populated map and the tile data doesn't need to change then setting this value to true will help with memory consumption. However if your map is small or you need to update the tiles dynamically, then leave the default value set.

Returns:
Description:

The created MapData object, or null if the data can't be parsed.

Since: 3.0.0
Focus
Focus
<static> ParseObject(tiledObject, [offsetX], [offsetY])
Focus
Focus

Description:

Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties id, name, type, rotation, properties, visible, x, y, width and height. Other properties will be added according to the object type (such as text, polyline, gid etc.)

Parameters:

name type arguments description
tiledObject object

Tiled object to convert to an internal parsed object normalising and copying properties over.

offsetX number <optional>

Optional additional offset to apply to the object's x property. Defaults to 0.

offsetY number <optional>

Optional additional offset to apply to the object's y property. Defaults to 0.

Returns:
Description:

The parsed object containing properties read from the Tiled object according to it's type with x and y values updated according to the given offsets.

Type:
  • object
Since: 3.0.0
Focus
Focus
<static> ParseObjectLayers(json)
Focus
Focus

Description:

Parses a Tiled JSON object into an array of ObjectLayer objects.

Parameters:

name type description
json object

The Tiled JSON object.

Returns:
Description:

An array of all object layers in the tilemap as ObjectLayers.

Type:
  • array
Focus
Focus
<static> ParseTileLayers(json, insertNull)
Focus
Focus

Description:

Parses all tilemap layers in a Tiled JSON object into new LayerData objects.

Parameters:

name type description
json object

The Tiled JSON object.

insertNull boolean

Controls how empty tiles, tiles with an index of -1, in the map data are handled (see {@link Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled}).

Returns:
Description:
  • An array of LayerData objects, one for each entry in json.layers with the type 'tilelayer'.
Focus
Focus
<static> ParseTilesets(json)
Focus
Focus

Description:

Tilesets and Image Collections.

Parameters:

name type description
json object

The Tiled JSON data.

Returns:
Description:

An object containing the tileset and image collection data.

Type:
  • object
Since: 3.0.0
Focus
Focus
<static> ParseWangsets(wangsets, datas)
Focus
Focus

Description:

Parses out the Wangset information from Tiled 1.1.5+ map data, if present.

Since a given tile can be in more than one wangset, the resulting properties are nested. tile.data.wangid[someWangsetName] will return the array-based wang id in this implementation.

Note that we're not guaranteed that there will be any 'normal' tiles if the only thing in the tilset are wangtile definitions, so this has to be parsed separately.

See https://doc.mapeditor.org/en/latest/manual/using-wang-tiles/ for more information.

Parameters:

name type description
wangsets Array.<object>

The array of wangset objects (parsed from JSON)

datas object

The field into which to put wangset data from Tiled.

Returns:
Description:

An object containing the tileset and image collection data.

Type:
  • object
Since: 3.53.0
Focus
Focus