Class: Phaser.AudioSprite
Constructor
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
- Source code: sound/AudioSprite.js (Line 48)
- Source code: sound/AudioSprite.js (Line 41)
- Source code: sound/AudioSprite.js (Line 35)
- Source code: sound/AudioSprite.js (Line 23)
- Source code: sound/AudioSprite.js (Line 29)
- Source code: sound/AudioSprite.js (Line 54)
autoplay : boolean
Is a sound set to autoplay or not?
autoplayKey : string
If a sound is set to auto play, this holds the marker key of it.
config : Object
JSON audio atlas object.
game : Phaser.Game
A reference to the currently running Game.
key : string
Asset key for the Audio Sprite.
sounds : Object
An object containing the Phaser.Sound objects for the Audio Sprite.
Public Methods
- Source code: sound/AudioSprite.js (Line 115)
- Source code: sound/AudioSprite.js (Line 77)
- Source code: sound/AudioSprite.js (Line 93)
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.
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.
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. |
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.AudioSprite.html