Load Audio Sprite Resources
Learn how to load and play audio sprites using a JSON configuration file and its associated audio resources.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.setPath('assets/audio/kyobi/');
this.load.audioSprite('kyobi', 'kyobi.json');
}
create ()
{
const music = this.sound.addAudioSprite('kyobi');
music.play('title');
// music.play('gameOver');
// music.play('nextLevel');
// text.setText('Playing Dafunk - Hardcore Power (We Believe In Goa - Remix)');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);