Created
February 21, 2015 02:04
-
-
Save corpsefilth/6a06e7c1346877caa102 to your computer and use it in GitHub Desktop.
Loading music assets. Phaser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load the music in 2 different formats, in the preload function | |
game.load.audio('music', ['assets/music.ogg', 'assets/music.mp3']); | |
// Add and start the music in the 'create' function | |
// Because we want to play the music when the play state starts | |
this.music = game.add.audio('music'); // Add the music | |
this.music.loop = true; // Make it loop | |
this.music.play(); // Start the music | |
// And don't forget to stop the music in the 'playerDie' function | |
// Otherwise the music would keep playing | |
this.music.stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment