Phaser.Textures.Parsers

Scope: static

Source: src/textures/parsers/index.js#L7

Methods:

Public Members

KTXParser

<static> KTXParser(data)

Description:

Parses a KTX format Compressed Texture file and generates texture data suitable for WebGL from it.

Parameters:

nametypeoptionaldescription
dataArrayBufferNoThe data object created by the Compressed Texture File Loader.

Returns: Phaser.Types.Textures.CompressedTextureData - The Compressed Texture data.

Source: src/textures/parsers/KTXParser.js#L7
Since: 3.60.0


PVRParser

<static> PVRParser(data)

Description:

Parses a PVR format Compressed Texture file and generates texture data suitable for WebGL from it.

Parameters:

nametypeoptionaldescription
dataArrayBufferNoThe data object created by the Compressed Texture File Loader.

Returns: Phaser.Types.Textures.CompressedTextureData - The Compressed Texture data.

Source: src/textures/parsers/PVRParser.js#L236
Since: 3.60.0


verifyCompressedTexture

<static> verifyCompressedTexture(data)

Description:

Verify whether the given compressed texture data is valid.

Compare the dimensions of each mip layer to the rules for that specific format.

Mip layer size is assumed to have been calculated correctly during parsing.

Parameters:

nametypeoptionaldescription
dataPhaser.Types.Textures.CompressedTextureDataNoThe compressed texture data to verify.

Returns: boolean - Whether the compressed texture data is valid.

Source: src/textures/parsers/VerifyCompressedTexture.js#L9
Since: 3.80.0


Private Members

AtlasXML

<static> AtlasXML(texture, sourceIndex, xml)

Description:

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

Access: private

Parameters:

nametypeoptionaldescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.
xml*NoThe XML data.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/AtlasXML.js#L7
Since: 3.7.0


Canvas

<static> Canvas(texture, sourceIndex)

Description:

Adds a Canvas Element to a Texture.

Access: private

Parameters:

nametypeoptionaldescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/Canvas.js#L7
Since: 3.0.0


Image

<static> Image(texture, sourceIndex)

Description:

Adds an Image Element to a Texture.

Access: private

Parameters:

nametypeoptionaldescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/Image.js#L7
Since: 3.0.0


JSONArray

<static> JSONArray(texture, sourceIndex, json)

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.

Access: private

Parameters:

nametypeoptionaldescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.
jsonobjectNoThe JSON data.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/JSONArray.js#L9
Since: 3.0.0


JSONHash

<static> JSONHash(texture, sourceIndex, json)

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.

Access: private

Parameters:

nametypeoptionaldescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.
jsonobjectNoThe JSON data.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/JSONHash.js#L9
Since: 3.0.0


SpriteSheet

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

Access: private

Parameters:

nametypeoptionaldefaultdescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.
xnumberNoThe top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases.
ynumberNoThe top-left coordinate of the Sprite Sheet. Defaults to zero. Used when extracting sheets from atlases.
widthnumberNoThe width of the source image.
heightnumberNoThe height of the source image.
configobjectNoAn object describing how to parse the Sprite Sheet.
config.frameWidthnumberNoWidth in pixels of a single frame in the sprite sheet.
config.frameHeightnumberYesHeight in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.
config.startFramenumberYes0The frame to start extracting from. Defaults to zero.
config.endFramenumberYes-1The frame to finish extracting at. Defaults to -1, which means 'all frames'.
config.marginnumberYes0If the frames have been drawn with a margin, specify the amount here.
config.spacingnumberYes0If the frames have been drawn with spacing between them, specify the amount here.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/SpriteSheet.js#L9
Since: 3.0.0


SpriteSheetFromAtlas

<static> SpriteSheetFromAtlas(texture, frame, 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, 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.

Access: private

Parameters:

nametypeoptionaldefaultdescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
framePhaser.Textures.FrameNoThe Frame that contains the Sprite Sheet.
configobjectNoAn object describing how to parse the Sprite Sheet.
config.frameWidthnumberNoWidth in pixels of a single frame in the sprite sheet.
config.frameHeightnumberYesHeight in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.
config.startFramenumberYes0Index of the start frame in the sprite sheet
config.endFramenumberYes-1Index of the end frame in the sprite sheet. -1 mean all the rest of the frames
config.marginnumberYes0If the frames have been drawn with a margin, specify the amount here.
config.spacingnumberYes0If the frames have been drawn with spacing between them, specify the amount here.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/SpriteSheetFromAtlas.js#L9
Since: 3.0.0


UnityYAML

<static> UnityYAML(texture, sourceIndex, yaml)

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

Access: private

Parameters:

nametypeoptionaldescription
texturePhaser.Textures.TextureNoThe Texture to add the Frames to.
sourceIndexnumberNoThe index of the TextureSource.
yamlobjectNoThe YAML data.

Returns: Phaser.Textures.Texture - The Texture modified by this parser.

Source: src/textures/parsers/UnityYAML.js#L38
Since: 3.0.0


Updated on