Phaser API Documentation

  Version: 
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:

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