Skip to main content
Version: Phaser v3.88.2

ObjectHelper

The ObjectHelper helps tie objects with gids into the tileset

that sits behind them.

Constructor

new ObjectHelper(tilesets)

Parameters

nametypeoptionaldescription
tilesetsArray.<Phaser.Tilemaps.Tileset>NoThe backing tileset data.

Scope: static

Source: src/tilemaps/ObjectHelper.js#L9
Since: 3.60.0

Public Members

enabled

enabled: boolean

Description:

Enabled if the object helper reaches in to tilesets for data.

Disabled if it only uses data directly on a gid object.

Source: src/tilemaps/ObjectHelper.js#L60
Since: 3.60.0


gids

gids: array

Description:

The Tile GIDs array.

Source: src/tilemaps/ObjectHelper.js#L27
Since: 3.60.0


Public Methods

getTypeIncludingTile

<instance> getTypeIncludingTile(obj)

Description:

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

Parameters:

nametypeoptionaldescription
objPhaser.Types.Tilemaps.TiledObjectNoThe Tiled object to investigate.

Returns: string - The type of the object, the tile behind the gid of the object, or undefined.

Source: src/tilemaps/ObjectHelper.js#L82
Since: 3.60.0


setPropertiesFromTiledObject

<instance> setPropertiesFromTiledObject(sprite, obj)

Description:

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

Parameters:

nametypeoptionaldescription
spritePhaser.GameObjects.GameObjectNoNo description provided
objPhaser.Types.Tilemaps.TiledObjectNoNo description provided

Source: src/tilemaps/ObjectHelper.js#L168
Since: 3.60.0


setTextureAndFrame

<instance> setTextureAndFrame(sprite, [key], [frame], [obj])

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:

nametypeoptionaldescription
spritePhaser.GameObjects.GameObjectNoThe Game Object to modify.
keystring | Phaser.Textures.TextureYesThe texture key to set (or else the obj.gid's tile is used if available).
framestring | numberPhaser.Textures.FrameYes
objPhaser.Types.Tilemaps.TiledObjectYesThe Tiled object for fallback.

Source: src/tilemaps/ObjectHelper.js#L121
Since: 3.60.0