Phaser API Documentation

  Version: 
setTexture(key, [frame], [updateSize], [updateOrigin])

Description:

Sets the texture and frame this Game Object will use to render with.

Textures are referenced by their string-based keys, as stored in the Texture Manager.

Calling this method will modify the width and height properties of your Game Object.

It will also change the origin if the Frame has a custom pivot point, as exported from packages like Texture Packer.

Parameters:

name type arguments Default description
key string | Phaser.Textures.Texture

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

frame string | number <optional>

The name or index of the frame within the Texture.

updateSize boolean <optional> true

Should this call adjust the size of the Game Object?

updateOrigin boolean <optional> true

Should this call change the origin of the Game Object?

Returns:
Description:

This Game Object instance.

Since: 3.0.0