Phaser API Documentation

  Version: 
addSpriteSheet(key, source, config, [dataSource])

Description:

Adds a Sprite Sheet to this Texture Manager.

In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact same size and cannot be trimmed or rotated. This is different to a Texture Atlas, created by tools such as Texture Packer, and more akin with the fixed-frame exports you get from apps like Aseprite or old arcade games.

As of Phaser 3.60 you can use this method to add a sprite sheet to an existing Phaser Texture.

Parameters:

name type arguments description
key string

The unique string-based key of the Texture. Give an empty string if you provide a Phaser Texture as the 2nd argument.

source HTMLImageElement | Phaser.Textures.Texture

The source Image element, or a Phaser Texture.

config Phaser.Types.Textures.SpriteSheetConfig

The configuration object for this Sprite Sheet.

dataSource HTMLImageElement | HTMLCanvasElement <optional>

An optional data Image element.

Returns:
Description:

The Texture that was created or updated, or null if the key is already in use.

Since: 3.0.0