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: Tilemaps
Phaser.Types.Tilemaps

Type Definitions

CreateFromObjectLayerConfig
Focus
Focus
Properties:
name type arguments Default description
id number <optional>

A unique Object ID to convert.

gid number <optional>

An Object GID to convert.

name string <optional>

An Object Name to convert.

classType Phaser.GameObjects.GameObject <optional> Phaser.GameObjects.Sprite

A custom class type to convert the objects in to.

scene Phaser.Scene <optional>

A Scene reference, passed to the Game Objects constructors.

container Phaser.GameObjects.Container <optional>

Optional Container to which the Game Objects are added.

key string | Phaser.Textures.Texture <optional>

Optional key of a Texture to be used, as stored in the Texture Manager, or a Texture instance.

frame string | number <optional>

Optional name or index of the frame within the Texture.

Type:
object
Focus
Focus
DebugStyleOptions
Focus
Focus
Properties:
name type arguments Default description
styleConfig.tileColor Phaser.Display.Color <optional> blue

Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn.

styleConfig.collidingTileColor Phaser.Display.Color <optional> orange

Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn.

styleConfig.faceColor Phaser.Display.Color <optional> grey

Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn.

Type:
object
Since: 3.0.0
Focus
Focus
FilteringOptions
Focus
Focus
Properties:
name type arguments Default description
isNotEmpty boolean <optional> false

If true, only return tiles that don't have -1 for an index.

isColliding boolean <optional> false

If true, only return tiles that collide on at least one side.

hasInterestingFace boolean <optional> false

If true, only return tiles that have at least one interesting face.

Type:
object
Since: 3.0.0
Focus
Focus
GIDData
Focus
Focus
Properties:
name type description
gid number

The Tiled GID.

flippedHorizontal boolean

Horizontal flip flag.

flippedVertical boolean

Vertical flip flag.

flippedAntiDiagonal boolean

Diagonal flip flag.

rotation number

Amount of rotation.

flipped boolean

Is flipped?

Type:
object
Since: 3.0.0
Focus
Focus
LayerDataConfig
Focus
Focus
Properties:
name type arguments Default description
name string <optional>

The name of the layer, if specified in Tiled.

x number <optional> 0

The x offset of where to draw from the top left.

y number <optional> 0

The y offset of where to draw from the top left.

width number <optional> 0

The width of the layer in tiles.

height number <optional> 0

The height of the layer in tiles.

tileWidth number <optional> 0

The pixel width of the tiles.

tileHeight number <optional> 0

The pixel height of the tiles.

baseTileWidth number <optional> 0

The base tile width.

baseTileHeight number <optional> 0

The base tile height.

widthInPixels number <optional> 0

The width in pixels of the entire layer.

heightInPixels number <optional> 0

The height in pixels of the entire layer.

alpha number <optional> 1

The alpha value of the layer.

visible boolean <optional> true

Is the layer visible or not?

properties Array.<object> <optional>

Layer specific properties (can be specified in Tiled)

indexes array <optional>

Tile ID index map.

collideIndexes array <optional>

Tile Collision ID index map.

callbacks array <optional>

An array of callbacks.

bodies array <optional>

An array of physics bodies.

data array <optional>

An array of the tile data indexes.

tilemapLayer Phaser.Tilemaps.TilemapLayer <optional>

A reference to the Tilemap layer that owns this data.

Type:
object
Since: 3.0.0
Focus
Focus
MapDataConfig
Focus
Focus
Properties:
name type arguments description
name string <optional>

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

width number <optional>

The width of the entire tilemap.

height number <optional>

The height of the entire tilemap.

tileWidth number <optional>

The width of the tiles.

tileHeight number <optional>

The height of the tiles.

widthInPixels number <optional>

The width in pixels of the entire tilemap.

heightInPixels number <optional>

The height in pixels of the entire tilemap.

format number <optional>

The format of the Tilemap, as defined in Tiled.

orientation string <optional>

The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'.

renderOrder string <optional>

Determines the draw order of tilemap. Default is right-down.

version number <optional>

The version of Tiled the map uses.

properties number <optional>

Map specific properties (can be specified in Tiled).

layers Array.<Phaser.Tilemaps.LayerData> <optional>

The layers of the tilemap.

images array <optional>

An array with all the layers configured to the MapData.

objects object <optional>

An array of Tiled Image Layers.

collision object <optional>

An object of Tiled Object Layers.

tilesets Array.<Phaser.Tilemaps.Tileset> <optional>

The tilesets the map uses.

imageCollections array <optional>

The collection of images the map uses(specified in Tiled).

tiles array <optional>

Array of Tile instances.

Type:
object
Since: 3.0.0
Focus
Focus
ObjectLayerConfig
Focus
Focus
Properties:
name type arguments Default description
name string <optional> 'object layer'

The name of the Object Layer.

opacity number <optional> 1

The opacity of the layer, between 0 and 1.

properties any <optional>

The custom properties defined on the Object Layer, keyed by their name.

propertytypes any <optional>

The type of each custom property defined on the Object Layer, keyed by its name.

type string <optional> 'objectgroup'

The type of the layer, which should be objectgroup.

visible boolean <optional> true

Whether the layer is shown (true) or hidden (false).

objects Array.<any> <optional>

An array of all objects on this Object Layer.

Type:
object
Since: 3.0.0
Focus
Focus
StyleConfig
Focus
Focus
Properties:
name type arguments Default description
tileColor number | null | Phaser.Display.Color <optional> blue

Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn.

collidingTileColor number | null | Phaser.Display.Color <optional> orange

Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn.

faceColor number | null | Phaser.Display.Color <optional> grey

Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn.

Type:
object
Since: 3.0.0
Focus
Focus
TiledObject
Focus
Focus
Properties:
name type arguments description
id number

The unique object ID.

name string

The name this object was assigned in Tiled.

type string

The string type of this instance, as assigned in Tiled. Tiled supports inheriting instance types from tilesets; in that case, the type will be set in the tile's data, but will be '' here; use the gid to fetch the tile data or properties.

visible boolean <optional>

The visible state of this object.

x number <optional>

The horizontal position of this object, in pixels, relative to the tilemap.

y number <optional>

The vertical position of this object, in pixels, relative to the tilemap.

width number <optional>

The width of this object, in pixels.

height number <optional>

The height of this object, in pixels.

rotation number <optional>

The rotation of the object in clockwise degrees.

properties any <optional>

Custom properties object.

gid number <optional>

Only set if of type 'tile'.

flippedHorizontal boolean <optional>

Only set if a tile object. The horizontal flip value.

flippedVertical boolean <optional>

Only set if a tile object. The vertical flip value.

flippedAntiDiagonal boolean <optional>

Only set if a tile object. The diagonal flip value.

polyline Array.<Phaser.Types.Math.Vector2Like> <optional>

Only set if a polyline object. An array of objects corresponding to points, where each point has an x property and a y property.

polygon Array.<Phaser.Types.Math.Vector2Like> <optional>

Only set if a polygon object. An array of objects corresponding to points, where each point has an x property and a y property.

text any <optional>

Only set if a text object. Contains the text objects properties.

rectangle boolean <optional>

Only set, and set to true, if a rectangle object.

ellipse boolean <optional>

Only set, and set to true, if a ellipse object.

point boolean <optional>

Only set, and set to true, if a point object.

Type:
object
Since: 3.0.0
Focus
Focus
TilemapConfig
Focus
Focus
Properties:
name type arguments Default description
key string <optional>

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

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

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

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.

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.

Type:
object
Since: 3.0.0
Focus
Focus