Phaser API Documentation

add(name, sourceIndex, x, y, width, height)


Adds a new Frame to this Texture.

A Frame is a rectangular region of a TextureSource with a unique index or string-based key.

The name given must be unique within this Texture. If it already exists, this method will return null.


name type description
name number | string

The name of this Frame. The name is unique within the Texture.

sourceIndex number

The index of the TextureSource that this Frame is a part of.

x number

The x coordinate of the top-left of this Frame.

y number

The y coordinate of the top-left of this Frame.

width number

The width of this Frame.

height number

The height of this Frame.


The Frame that was added to this Texture, or null if the given name already exists.

Inherited from: Phaser.Textures.Texture#add
Since: 3.0.0
Source: src/textures/Texture.js (Line 137)