Phaser API Documentation

  Version: 
Filter

The ObjectHelper helps tie objects with gids into the tileset that sits behind them.

Constructor:

new ObjectHelper(tilesets)

Parameters:

name type description
tilesets Array.<Phaser.Tilemaps.Tileset>

The backing tileset data.

Since: 3.60.0

Members

<private> _gids: array
Focus
Focus

Description:

The Tile GIDs array.

Type:
array
Since: 3.60.0
Focus
Focus
enabled: boolean
Focus
Focus

Description:

Enabled if the object helper reaches in to tilesets for data. Disabled if it only uses data directly on a gid object.

Type:
boolean
Since: 3.60.0
Focus
Focus
gids: array
Focus
Focus

Description:

The Tile GIDs array.

Type:
array
Since: 3.60.0
Focus
Focus

Methods

getTypeIncludingTile(obj)
Focus
Focus

Description:

Gets the Tiled type field value from the object or the gid behind it.

Parameters:

name type description
obj Phaser.Types.Tilemaps.TiledObject

The Tiled object to investigate.

Returns:
Description:

The type of the object, the tile behind the gid of the object, or undefined.

Type:
  • string
Since: 3.60.0
Focus
Focus
<private> setFromJSON(sprite, properties)
Focus
Focus

Description:

Sets the sprite data from the JSON object.

Parameters:

name type description
sprite Phaser.GameObjects.GameObject

The object for which to populate data.

properties Object.<string, *> | Array.<Object>

The properties to set in either JSON object format or else a list of objects with name and value fields.

Since: 3.60.0
Focus
Focus
setPropertiesFromTiledObject(sprite, obj)
Focus
Focus

Description:

Sets the sprite.data field from the tiled properties on the object and its tile (if any).

Parameters:

Since: 3.60.0
Focus
Focus
setTextureAndFrame(sprite, [key], [frame], [obj])
Focus
Focus

Description:

Sets the sprite texture data as specified (usually in a config) or, failing that, as specified in the gid of the object being loaded (if any).

This fallback will only work if the tileset was loaded as a spritesheet matching the geometry of sprites fed into tiled, so that, for example: "tile id #3"" within the tileset is the same as texture frame 3 from the image of the tileset.

Parameters:

name type arguments description
sprite Phaser.GameObjects.GameObject

The Game Object to modify.

key string | Phaser.Textures.Texture <optional>

The texture key to set (or else the obj.gid's tile is used if available).

frame string | number | Phaser.Textures.Frame <optional>

The frames key to set (or else the obj.gid's tile is used if available).

obj Phaser.Types.Tilemaps.TiledObject <optional>

The Tiled object for fallback.

Since: 3.60.0
Focus
Focus