/
sound.js
35 lines (32 loc) · 1 KB
/
sound.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
sound = {
load: function() {
game.load.audio('menu', 'menu.ogg');
game.load.audio('shoot1', 'shoot.ogg');
game.load.audio('shoot2', 'shoot2.ogg');
game.load.audio('shoot3', 'laser.ogg');
game.load.audio('gameover', 'gameover.ogg');
game.load.audio('hit', 'hit.ogg');
game.load.audio('shunt', 'shunt.ogg');
game.load.audio('spawnerdeath', 'spawndeath.ogg');
game.load.audio('spawnerhit', 'spawnerhit.ogg');
game.load.audio('spawn', 'spawn.ogg');
},
create: function() {
this.menu = new Sound('menu');
this.shoot = new Sound('shoot2');
this.gameover = new Sound('gameover');
this.hit = new Sound('hit');
this.shunt = new Sound('shunt');
this.spawnerDeath = new Sound('spawnerdeath');
this.spawnerHit = new Sound('spawnerhit');
this.spawn = new Sound('spawn');
}
}
var SOUND_ENABLED = true;
function Sound(name) {
this._gameObj = game.add.audio(name, 1);
}
Sound.prototype.play = function() {
if (SOUND_ENABLED)
this._gameObj.play();
}