Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord
Namespace: Texture
Phaser.GameObjects.Components.Texture

Members

Description:

The Texture Frame this Game Object is using to render with.

Type:
Since: 3.0.0
Focus
Focus
<private> isCropped: boolean
Focus
Focus

Description:

Internal flag. Not to be set by this Game Object.

Type:
boolean
Since: 3.11.0
Focus
Focus

Description:

The Texture this Game Object is using to render with.

Type:
Since: 3.0.0
Focus
Focus

Methods

setTexture(key, [frame])
Focus
Focus

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.

Parameters:

name type arguments 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.

Returns:
Description:

This Game Object instance.

Examples:
Since: 3.0.0
Focus
Focus
setFrame(frame, [updateSize], [updateOrigin])
Focus
Focus

Description:

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

The Frame has to belong to the current Texture being used.

It can be either a string or an index.

Calling setFrame 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
frame string | number

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 adjust the origin of the Game Object?

Returns:
Description:

This Game Object instance.

Examples:
Since: 3.0.0
Focus
Focus