You’re reading the docs for Phaser v3.88.2. The latest is Phaser v4.1.0.

Phaser.Tilemaps.Parsers

Scope: static

Source: src/tilemaps/parsers/index.js#L7

Static functions

FromOrientationString

staticFromOrientationString([orientation])

Description:

Get the Tilemap orientation from the given string.

Parameters:

nametypeoptionaldescription
orientationstringYesThe orientation type as a string.

Returns: Phaser.Tilemaps.OrientationType - The Tilemap Orientation type.

Source: src/tilemaps/parsers/FromOrientationString.js#L9
Since: 3.50.0


Parse

staticParse(name, mapFormat, data, tileWidth, tileHeight, insertNull)

Description:

Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format

is found, returns null. When loading from CSV or a 2D array, you should specify the tileWidth &

tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from

the map data.

Parameters:

nametypeoptionaldescription
namestringNoThe name of the tilemap, used to set the name on the MapData.
mapFormatnumberNoSee ../Formats.js.
dataArray.<Array.<number>> | stringobjectNo
tileWidthnumberNoThe width of a tile in pixels. Required for 2D array and CSV, but ignored for Tiled JSON.
tileHeightnumberNoThe height of a tile in pixels. Required for 2D array and CSV, but ignored for Tiled JSON.
insertNullbooleanNoControls 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: Phaser.Tilemaps.MapData - The created MapData object.

Source: src/tilemaps/parsers/Parse.js#L13
Since: 3.0.0


Parse2DArray

staticParse2DArray(name, data, tileWidth, tileHeight, insertNull)

Description:

Parses a 2D array of tile indexes into a new MapData object with a single layer.

Parameters:

nametypeoptionaldescription
namestringNoThe name of the tilemap, used to set the name on the MapData.
dataArray.<Array.<number>>No2D array, CSV string or Tiled JSON object.
tileWidthnumberNoThe width of a tile in pixels.
tileHeightnumberNoThe height of a tile in pixels.
insertNullbooleanNoControls 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: Phaser.Tilemaps.MapData - The MapData object.

Source: src/tilemaps/parsers/Parse2DArray.js#L12
Since: 3.0.0


ParseCSV

staticParseCSV(name, data, tileWidth, tileHeight, insertNull)

Description:

Parses a CSV string of tile indexes into a new MapData object with a single layer.

Parameters:

nametypeoptionaldescription
namestringNoThe name of the tilemap, used to set the name on the MapData.
datastringNoCSV string of tile indexes.
tileWidthnumberNoThe width of a tile in pixels.
tileHeightnumberNoThe height of a tile in pixels.
insertNullbooleanNoControls 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: Phaser.Tilemaps.MapData - The resulting MapData object.

Source: src/tilemaps/parsers/ParseCSV.js#L10
Since: 3.0.0


Static functions