Namespace: Texture

Phaser.GameObjects.Components. Texture

Provides methods used for getting and setting the texture of a Game Object.

Since: 3.0.0
Source: src/gameobjects/components/Texture.js (Line 10)

Members


frame :Phaser.Textures.Frame

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

Type:
Since: 3.0.0
Source: src/gameobjects/components/Texture.js (Line 28)

texture :Phaser.Textures.Texture|Phaser.Textures.CanvasTexture

The Texture this Game Object is using to render with.

Type:
Since: 3.0.0
Source: src/gameobjects/components/Texture.js (Line 19)

Methods


setFrame(frame [, updateSize] [, updateOrigin])

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 Argument 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?

Since: 3.0.0
Source: src/gameobjects/components/Texture.js (Line 67)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Texture

setTexture(key [, frame])

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 Argument 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.

Since: 3.0.0
Source: src/gameobjects/components/Texture.js (Line 47)
Returns:

This Game Object instance.

Type
Phaser.GameObjects.Components.Texture