Phaser API Documentation

  Version: 
Filter

A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled object layer, except:

  • "x" & "y" properties are ignored since these cannot be changed in Tiled.
  • "offsetx" & "offsety" are applied to the individual object coordinates directly, so they are ignored as well.
  • "draworder" is ignored.

Constructor:

new ObjectLayer([config])

Parameters:

name type arguments description
config Phaser.Types.Tilemaps.ObjectLayerConfig <optional>

The data for the layer from the Tiled JSON object.

Since: 3.0.0

Members

id: number
Focus
Focus

Description:

The id of the object layer, as specified in the map data.

Type:
number
Since: 3.70.0
Focus
Focus
name: string
Focus
Focus

Description:

The name of the Object Layer.

Type:
string
Since: 3.0.0
Focus
Focus

Description:

An array of all objects on this Object Layer.

Each Tiled object corresponds to a JavaScript object in this array. It has an id (unique), name (as assigned in Tiled), type (as assigned in Tiled), rotation (in clockwise degrees), properties (if any), visible state (true if visible, false otherwise), x and y coordinates (in pixels, relative to the tilemap), and a width and height (in pixels).

An object tile has a gid property (GID of the represented tile), a flippedHorizontal property, a flippedVertical property, and flippedAntiDiagonal property. The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains information on flipping and rotation.

Polylines have a polyline property, which is an array of objects corresponding to points, where each point has an x property and a y property. Polygons have an identically structured array in their polygon property. Text objects have a text property with the text's properties.

Rectangles and ellipses have a rectangle or ellipse property set to true.

Type:
Since: 3.0.0
Focus
Focus
opacity: number
Focus
Focus

Description:

The opacity of the layer, between 0 and 1.

Type:
number
Since: 3.0.0
Focus
Focus
properties: object
Focus
Focus

Description:

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

Type:
object
Since: 3.0.0
Focus
Focus
propertyTypes: object
Focus
Focus

Description:

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

Type:
object
Since: 3.0.0
Focus
Focus
type: string
Focus
Focus

Description:

The type of the layer, which should be objectgroup.

Type:
string
Since: 3.0.0
Focus
Focus
visible: boolean
Focus
Focus

Description:

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

Type:
boolean
Since: 3.0.0
Focus
Focus