Namespace: Tilemaps

Phaser. Tilemaps

Classes

ImageCollection
LayerData
MapData
ObjectLayer
Tile
Tilemap
TilemapLayer
Tileset

Namespaces

Components
Formats
Orientation
Parsers

Members


<static, constant> HEXAGONAL :number

Hexagonal Tilemap orientation constant.

Type:
  • number
Since: 3.50.0
Source: src/tilemaps/const/ORIENTATION_CONST.js (Line 57)

<static, constant> ISOMETRIC :number

Isometric Tilemap orientation constant.

Type:
  • number
Since: 3.50.0
Source: src/tilemaps/const/ORIENTATION_CONST.js (Line 37)

<static, constant> ORTHOGONAL :number

Orthogonal Tilemap orientation constant.

Type:
  • number
Since: 3.50.0
Source: src/tilemaps/const/ORIENTATION_CONST.js (Line 27)

<static, constant> STAGGERED :number

Staggered Tilemap orientation constant.

Type:
  • number
Since: 3.50.0
Source: src/tilemaps/const/ORIENTATION_CONST.js (Line 47)

Methods


<static> ParseToTilemap(scene [, key] [, tileWidth] [, tileHeight] [, width] [, height] [, data] [, insertNull])

Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For an empty map, you should specify tileWidth, tileHeight, width & height.

Parameters:
Name Type Argument Default Description
scene Phaser.Scene

The Scene to which this Tilemap belongs.

key string <optional>

The key in the Phaser cache that corresponds to the loaded tilemap data.

tileWidth number <optional>
32

The width of a tile in pixels.

tileHeight number <optional>
32

The height of a tile in pixels.

width number <optional>
10

The width of the map in tiles.

height number <optional>
10

The height of the map in tiles.

data Array.<Array.<number>> <optional>

Instead of loading from the cache, you can also load directly from a 2D array of tile indexes.

insertNull boolean <optional>
false

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.

Since: 3.0.0
Source: src/tilemaps/ParseToTilemap.js (Line 12)
Returns:
Type
Phaser.Tilemaps.Tilemap

Type Definitions


OrientationType

Phaser Tilemap constants for orientation.

To find out what each mode does please see Phaser.Tilemaps.Orientation.

Type:
Since: 3.50.0
Source: src/tilemaps/const/ORIENTATION_CONST.js (Line 15)