Skip to main content
Version: Phaser v4.0.0

Phaser.Tilemaps.Parsers

Scope: static

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

Static functions

FromOrientationString

<static> FromOrientationString([orientation])

Description:

Converts a Tilemap orientation string into the corresponding Phaser.Tilemaps.OrientationType constant. Recognized values are 'isometric', 'staggered', and 'hexagonal'. Any other string, including 'orthogonal', will return the orthogonal orientation constant, which is the default grid-based orientation used by most tilemaps.

The comparison is case-insensitive.

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

<static> Parse(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.
mapFormatnumberNoThe format of the map data. Must be one of the Phaser.Tilemaps.Formats constants, such as Phaser.Tilemaps.Formats.TILED_JSON.
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, or null if the map format was not recognized.

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


Parse2DArray

<static> Parse2DArray(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>>NoA 2D array 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 locations will get a Tile object with an index of -1. If you have 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

<static> ParseCSV(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