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: Parsers
Phaser.Textures.Parsers

Methods

<static, private> AtlasXML(texture, sourceIndex, xml)
Focus
Focus

Description:

Parses an XML Texture Atlas object and adds all the Frames into a Texture.

Parameters:

name type description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

xml *

The XML data.

Returns:
Description:

The Texture modified by this parser.

Examples:
Since: 3.7.0
Focus
Focus
<static, private> Canvas(texture, sourceIndex)
Focus
Focus

Description:

Adds a Canvas Element to a Texture.

Parameters:

name type description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

Returns:
Description:

The Texture modified by this parser.

Examples:
Since: 3.0.0
Focus
Focus
<static, private> Image(texture, sourceIndex)
Focus
Focus

Description:

Adds an Image Element to a Texture.

Parameters:

name type description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

Returns:
Description:

The Texture modified by this parser.

Examples:
Since: 3.0.0
Focus
Focus
<static, private> JSONArray(texture, sourceIndex, json)
Focus
Focus

Description:

Parses a Texture Atlas JSON Array and adds the Frames to the Texture. JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames.

Parameters:

name type description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

json object

The JSON data.

Returns:
Description:

The Texture modified by this parser.

Examples:
Since: 3.0.0
Focus
Focus
<static, private> JSONHash(texture, sourceIndex, json)
Focus
Focus

Description:

Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames.

Parameters:

name type description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

json object

The JSON data.

Returns:
Description:

The Texture modified by this parser.

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

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.

Examples:
Since: 3.0.0
Focus
Focus
<static, private> SpriteSheetFromAtlas(texture, frame, config, config.frameWidth, [config.frameHeight], [config.startFrame], [config.endFrame], [config.margin], [config.spacing])
Focus
Focus

Description:

Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas.

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.

frame Phaser.Textures.Frame

The Frame that contains the Sprite Sheet.

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

Index of the start frame in the sprite sheet

config.endFrame number <optional> -1

Index of the end frame in the sprite sheet. -1 mean all the rest of the 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.

Examples:
Since: 3.0.0
Focus
Focus
<static, private> UnityYAML(texture, sourceIndex, yaml)
Focus
Focus

Description:

Parses a Unity YAML File and creates Frames in the Texture. For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html

Parameters:

name type description
texture Phaser.Textures.Texture

The Texture to add the Frames to.

sourceIndex number

The index of the TextureSource.

yaml object

The YAML data.

Returns:
Description:

The Texture modified by this parser.

Examples:
Since: 3.0.0
Focus
Focus