Skip to content

Commit b3d9951

Browse files
committed
add alien sounds
1 parent d0d7cc1 commit b3d9951

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/js/elementfactory.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var ElementFactory = function (game) {
2020
sprite.docked = false;
2121
sprite.isShip = true;
2222
sprite.dockedTime = 0;
23+
sprite.deathSound = _game.add.audio('alien_explode');
24+
sprite.dockSound = _game.add.audio('alien_dock');
2325
sprite.moveForward = function (speed) {
2426
if (!this.docked) {
2527
if (_game.physics.arcade.distanceToXY(this.position, _game.world.centerX, _game.world.centerY) > _game.world.width * 2) {
@@ -53,6 +55,7 @@ var ElementFactory = function (game) {
5355
bullet = sprite1.isbullet !== undefined ? sprite1 : bullet;
5456
bullet = sprite2.isbullet !== undefined ? sprite2 : bullet;
5557
if (planet !== null && ship !== null && !ship.docked) {
58+
ship.dockSound.play();
5659
ship.animations.play('dock', null, false);
5760
ship.docked = true;
5861
ship.dockedTime = new Date();
@@ -66,6 +69,7 @@ var ElementFactory = function (game) {
6669
}
6770
if (ship.speedMultiplier > 1) {
6871
clearInterval(ship.drainInterval);
72+
sprite.deathSound.play();
6973
ship.animations.play('death-pull', null, false);
7074
ship.animations.currentAnim.onComplete.add(function () {
7175
ship.kill();
@@ -103,8 +107,10 @@ var ElementFactory = function (game) {
103107
sprite.isPlanet = true;
104108
sprite.lastRegen = 0;
105109
sprite.cooldown = 1000;
110+
sprite.regenSound = _game.add.audio('load_energy');
106111
sprite.regenerate = function () {
107112
if (new Date() - this.lastRegen > this.cooldown && this.energy < 50) {
113+
// sprite.regenSound.play(); // sound is too long
108114
this.lastRegen = new Date();
109115
this.energy++;
110116
}
@@ -218,7 +224,6 @@ var ElementFactory = function (game) {
218224
} else {
219225
bullet.btnSound = _game.add.audio('gravity_minus');
220226
}
221-
;
222227
_game.sound.setDecodedCallback([bullet.btnSound], function () {
223228
}, this);
224229
bullet.btnSound.play();

0 commit comments

Comments
 (0)