Playing some music
One of the lively aspects of games is the music. Here is a crisp recipe to play music. The output of this recipe looks as follows. Of course, unless you try this example, you will not be able to listen to the music:
How to do it…
The HTML code is as follows:
<html> <head> <meta charset="UTF-8" /> <title>Playing Music</title> <script src="../phaser-master/build/phaser.min.js"></script> </head> <body> <script type="text/javascript"> var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', {preload: preload,create: create,update: update,render: render}); var music; var play; var stop; function preload() { game.load.audio('bkgmusic',['music/background1.mp3']); game.load.image('play','gameimages/playbutton.png'); game.load.image('stop','gameimages/stopbutton.png'); } function create() { music = game...