Navigation
These archived docs are for Phaser 2.6.1 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. AudioSprite

new AudioSprite(game, key)

Audio Sprites are a combination of audio files and a JSON configuration. The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite

Parameters
Name Type Description
game Phaser.Game

Reference to the current game instance.

key string

Asset key for the sound.

Source code: sound/AudioSprite.js (Line 17)

Public Properties

autoplay : boolean

Is a sound set to autoplay or not?

Source code: sound/AudioSprite.js (Line 48)

autoplayKey : string

If a sound is set to auto play, this holds the marker key of it.

Source code: sound/AudioSprite.js (Line 41)

config : Object

JSON audio atlas object.

Source code: sound/AudioSprite.js (Line 35)

game : Phaser.Game

A reference to the currently running Game.

Source code: sound/AudioSprite.js (Line 23)

key : string

Asset key for the Audio Sprite.

Source code: sound/AudioSprite.js (Line 29)

sounds : Object

An object containing the Phaser.Sound objects for the Audio Sprite.

Source code: sound/AudioSprite.js (Line 54)

Public Methods

get(marker) → {Phaser.Sound}

Get a sound with the given name.

Parameters
Name Type Description
marker string

The name of sound to get.

Returns

The sound instance.

Source code: sound/AudioSprite.js (Line 115)

play(marker, volume) → {Phaser.Sound}

Play a sound with the given name.

Parameters
Name Type Argument Default Description
marker string <optional>

The name of sound to play

volume number <optional>
1

Volume of the sound you want to play. If none is given it will use the volume given to the Sound when it was created (which defaults to 1 if none was specified).

Returns

This sound instance.

Source code: sound/AudioSprite.js (Line 77)

stop(marker)

Stop a sound with the given name.

Parameters
Name Type Argument Default Description
marker string <optional>
''

The name of sound to stop. If none is given it will stop all sounds in the audio sprite.

Source code: sound/AudioSprite.js (Line 93)