Class: TilemapParser

Phaser. TilemapParser

new TilemapParser()

Phaser.TilemapParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into a Tilemap.

Source:
src/tilemap/TilemapParser.js line 13

Members

<static, constant> INSERT_NULL : boolean

When scanning the Tiled map data the TilemapParser can either insert a null value (true) or a Phaser.Tile instance with an index of -1 (false, the default). Depending on your game type depends how this should be configured. 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 (perhaps the map dynamically changes during the game) then leave the default value set.

Type:
  • boolean
Source:
src/tilemap/TilemapParser.js line 26

Methods

<static> getEmptyData()

Returns an empty map data object.

Source:
src/tilemap/TilemapParser.js line 133
Returns:

Generated map data.

Type
object

<static> parse(game, key [, tileWidth] [, tileHeight] [, width] [, height])

Parse tilemap data from the cache and creates data for a Tilemap object.

Parameters:
Name Type Argument Default Description
game Phaser.Game

Game reference to the currently running game.

key string

The key of the tilemap in the Cache.

tileWidth number <optional>
32

The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data.

tileHeight number <optional>
32

The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data.

width number <optional>
10

The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this.

height number <optional>
10

The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this.

Source:
src/tilemap/TilemapParser.js line 28
Returns:

The parsed map object.

Type
object

<static> parseCSV(key, data [, tileWidth] [, tileHeight])

Parses a CSV file into valid map data.

Parameters:
Name Type Argument Default Description
key string

The name you want to give the map data.

data string

The CSV file data.

tileWidth number <optional>
32

The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data.

tileHeight number <optional>
32

The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data.

Source:
src/tilemap/TilemapParser.js line 76
Returns:

Generated map data.

Type
object

<static> parseObjectGroup(objectGroup, objectsCollection, collisionCollection [, nameKey] [, relativePosition])

Parses an object group in Tiled JSON files. Object groups can be found in both layers and tilesets. Called internally in parseTiledJSON.

Parameters:
Name Type Argument Default Description
objectGroup object

A JSON object group.

objectsCollection object

An object into which new array of Tiled map objects will be added.

collisionCollection object

An object into which new array of collision objects will be added. Currently only polylines are added.

nameKey string <optional>
objectGroup.name

Key under which to store objects in collisions in objectsCollection and collisionCollection

relativePosition object <optional>
{x: 0, y: 0}

Coordinates the object group's position is relative to.

Source:
src/tilemap/TilemapParser.js line 233
Returns:

A object literal containing the objectsCollection and collisionCollection

Type
object

<static> parseTiledJSON(json)

Parses a Tiled JSON file into valid map data.

Parameters:
Name Type Description
json object

The JSON map data.

Source:
src/tilemap/TilemapParser.js line 312
Returns:

Generated and parsed map data.

Type
object

phaser-ce@2.20.0 is on GitHub and NPM

Documentation generated by JSDoc 3.6.7 on 2022-12-10 using Tomorrow.