LayerData
Stores all data associated with a single layer in a tilemap. When a map is parsed from CSV, Tiled JSON, or other formats, each tile layer is converted into a LayerData instance that holds the tile grid, layer dimensions, orientation, visibility, physics bodies, tile callbacks, and any custom properties defined in the editor.
Both Tilemap and TilemapLayer hold a reference to LayerData and use it to look up tile positions, perform collision checks, and drive rendering.
Constructor
new LayerData([config])
Parameters
| name | type | optional | description |
|---|---|---|---|
| config | Phaser.Types.Tilemaps.LayerDataConfig | Yes | The Layer Data configuration object. |
Scope: static
Source: src/tilemaps/mapdata/LayerData.js#L11
Since: 3.0.0
Public Members
alpha
alpha: number
Description:
The alpha value of the layer.
Source: src/tilemaps/mapdata/LayerData.js#L159
Since: 3.0.0
baseTileHeight
baseTileHeight: number
Description:
The base tile height, in pixels. This is the tile height defined at the map level and is used to calculate pixel coordinates and layer dimensions. It defaults to tileHeight but may differ for layers that use a different tile size than the map default.
Source: src/tilemaps/mapdata/LayerData.js#L121
Since: 3.0.0
baseTileWidth
baseTileWidth: number
Description:
The base tile width, in pixels. This is the tile width defined at the map level and is used to calculate pixel coordinates and layer dimensions. It defaults to tileWidth but may differ for layers that use a different tile size than the map default.
Source: src/tilemaps/mapdata/LayerData.js#L110
Since: 3.0.0
bodies
bodies: array
Description:
An array of physics bodies.
Source: src/tilemaps/mapdata/LayerData.js#L215
Since: 3.0.0
callbacks
callbacks: array
Description:
An array of tile location callbacks registered for this layer. Each entry maps a tile index to a callback function that is invoked when a physics-enabled Game Object overlaps or collides with that tile.
Source: src/tilemaps/mapdata/LayerData.js#L204
Since: 3.0.0
collideIndexes
collideIndexes: array
Description:
Tile Collision ID index map.
Source: src/tilemaps/mapdata/LayerData.js#L195
Since: 3.0.0
data
data: Array.<Array.<Phaser.Tilemaps.Tile>>
Description:
A 2D array of Tile objects representing the tile grid for this layer. Indexed as data[row][col], where each entry is a Tile instance (or null for an empty cell).
Source: src/tilemaps/mapdata/LayerData.js#L224
Since: 3.0.0
height
height: number
Description:
The height of the layer in tiles.
Source: src/tilemaps/mapdata/LayerData.js#L83
Since: 3.0.0
heightInPixels
heightInPixels: number
Description:
The height in pixels of the entire layer.
Source: src/tilemaps/mapdata/LayerData.js#L150
Since: 3.0.0
hexSideLength
hexSideLength: number
Description:
The length of the horizontal sides of the hexagon. Only used for hexagonal orientation Tilemaps.
Source: src/tilemaps/mapdata/LayerData.js#L243
Since: 3.50.0
id
id: number
Description:
The id of the layer, as specified in the map data.
Note: This is not the index of the layer in the map data, but its actual ID in Tiled.
Source: src/tilemaps/mapdata/LayerData.js#L45
Since: 3.70.0
indexes
indexes: array
Description:
Tile ID index map.
Source: src/tilemaps/mapdata/LayerData.js#L186
Since: 3.0.0
name
name: string
Description:
The name of the layer, if specified in Tiled.
Source: src/tilemaps/mapdata/LayerData.js#L36
Since: 3.0.0
orientation
orientation: Phaser.Tilemaps.OrientationType
Description:
The layer's orientation, necessary to be able to determine a tile's pixelX and pixelY as well as the layer's width and height.
Source: src/tilemaps/mapdata/LayerData.js#L132
Since: 3.50.0
properties
properties: Array.<object>
Description:
Layer specific properties (can be specified in Tiled).
Source: src/tilemaps/mapdata/LayerData.js#L177
Since: 3.0.0
staggerAxis
staggerAxis: string
Description:
The Stagger Axis as defined in Tiled.
Only used for hexagonal orientation Tilemaps.
Source: src/tilemaps/mapdata/LayerData.js#L253
Since: 3.60.0
staggerIndex
staggerIndex: string
Description:
The Stagger Index as defined in Tiled.
Either 'odd' or 'even'.
Only used for hexagonal orientation Tilemaps.
Source: src/tilemaps/mapdata/LayerData.js#L264
Since: 3.60.0
tileHeight
tileHeight: number
Description:
The pixel height of the tiles.
Source: src/tilemaps/mapdata/LayerData.js#L101
Since: 3.0.0
tilemapLayer
tilemapLayer: Phaser.Tilemaps.TilemapLayer
Description:
A reference to the Tilemap layer that owns this data.
Source: src/tilemaps/mapdata/LayerData.js#L234
Since: 3.0.0
tileWidth
tileWidth: number
Description:
The pixel width of the tiles.
Source: src/tilemaps/mapdata/LayerData.js#L92
Since: 3.0.0
visible
visible: boolean
Description:
Is the layer visible or not?
Source: src/tilemaps/mapdata/LayerData.js#L168
Since: 3.0.0
width
width: number
Description:
The width of the layer in tiles.
Source: src/tilemaps/mapdata/LayerData.js#L74
Since: 3.0.0
widthInPixels
widthInPixels: number
Description:
The width in pixels of the entire layer.
Source: src/tilemaps/mapdata/LayerData.js#L141
Since: 3.0.0
x
x: number
Description:
The x offset of where to draw from the top left.
Source: src/tilemaps/mapdata/LayerData.js#L56
Since: 3.0.0
y
y: number
Description:
The y offset of where to draw from the top left.
Source: src/tilemaps/mapdata/LayerData.js#L65
Since: 3.0.0