Class: AudioSprite

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:
src/sound/AudioSprite.js line 17

Members

autoplay : boolean

Is a sound set to autoplay or not?

Type:
  • boolean
Source:
src/sound/AudioSprite.js line 48

autoplayKey : string

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

Type:
  • string
Source:
src/sound/AudioSprite.js line 41

config : object

JSON audio atlas object.

Type:
  • object
Source:
src/sound/AudioSprite.js line 35

game : Phaser.Game

A reference to the currently running Game.

Type:
Source:
src/sound/AudioSprite.js line 23

key : string

Asset key for the Audio Sprite.

Type:
  • string
Source:
src/sound/AudioSprite.js line 29

sounds : object

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

Type:
  • object
Source:
src/sound/AudioSprite.js line 54

Methods

get(marker)

Get a sound with the given name.

Parameters:
Name Type Description
marker string

The name of sound to get.

Source:
src/sound/AudioSprite.js line 112
Returns:

The sound instance.

Type
Phaser.Sound

play( [marker] [, volume])

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

Source:
src/sound/AudioSprite.js line 76
Returns:

This sound instance.

Type
Phaser.Sound

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:
src/sound/AudioSprite.js line 91

phaser-ce@2.20.1 is on GitHub and NPM

Documentation generated by JSDoc 3.6.11 on 2024-10-05 using Tomorrow.