Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Parsers
Phaser.Tilemaps.Parsers

Namespace

Methods

<static> FromOrientationString([orientation])
Focus
Focus

Description:

Get the Tilemap orientation from the given string.

Parameters:

name type arguments description
orientation string <optional>

The orientation type as a string.

Returns:
Description:

The Tilemap Orientation type.

Examples:
Since: 3.50.0
Focus
Focus
<static> Parse(name, mapFormat, data, tileWidth, tileHeight, insertNull)
Focus
Focus

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:

name type description
name string

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

mapFormat number

See ../Formats.js.

data Array.<Array.<number>> | string | object

2D array, CSV string or Tiled JSON object.

tileWidth number

The width of a tile in pixels. Required for 2D array and CSV, but ignored for Tiled JSON.

tileHeight number

The height of a tile in pixels. Required for 2D array and CSV, but ignored for Tiled JSON.

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.

Examples:
Since: 3.0.0
Focus
Focus
<static> Parse2DArray(name, data, tileWidth, tileHeight, insertNull)
Focus
Focus

Description:

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

Parameters:

name type description
name string

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

data Array.<Array.<number>>

2D array, CSV string or Tiled JSON object.

tileWidth number

The width of a tile in pixels.

tileHeight number

The height of a tile in pixels.

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 MapData object.

Examples:
Since: 3.0.0
Focus
Focus
<static> ParseCSV(name, data, tileWidth, tileHeight, insertNull)
Focus
Focus

Description:

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

Parameters:

name type description
name string

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

data string

CSV string of tile indexes.

tileWidth number

The width of a tile in pixels.

tileHeight number

The height of a tile in pixels.

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 resulting MapData object.

Examples:
Since: 3.0.0
Focus
Focus