Phaser API Documentation

  Version: 
<static, private> SpriteSheet(texture, sourceIndex, x, y, width, height, config, config.frameWidth, [config.frameHeight], [config.startFrame], [config.endFrame], [config.margin], [config.spacing])

Description:

Parses a Sprite Sheet and adds the Frames to the Texture.

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.

Parameters:

name type arguments Default description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

x number

The top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases.

y number

The top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases.

width number

The width of the source image.

height number

The height of the source image.

config object

An object describing how to parse the Sprite Sheet.

config.frameWidth number

Width in pixels of a single frame in the sprite sheet.

config.frameHeight number <optional>

Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.

config.startFrame number <optional> 0

The frame to start extracting from. Defaults to zero.

config.endFrame number <optional> -1

The frame to finish extracting at. Defaults to -1, which means 'all frames'.

config.margin number <optional> 0

If the frames have been drawn with a margin, specify the amount here.

config.spacing number <optional> 0

If the frames have been drawn with spacing between them, specify the amount here.

Returns:
Description:

The Texture modified by this parser.

Since: 3.0.0