1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | // ex05. Audio
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'ex05',
{ preload: preload, create: create});
function preload() {
game.load.audio('ex05Sound', 'sounds/ex05.mp3');
}
function create() {
// Set backgound color
game.stage.backgroundColor = "#0FFF0F";
// sound
this.sound = game.add.audio("ex05Sound");
// call playSound if click detected
game.input.onDown.add(playSound, this);
}
function playSound() {
// Play sound
this.sound.play()
}
|
No comments:
Post a Comment