Added ship change sound
This commit is contained in:
parent
97771a9b0a
commit
7ad81617f3
BIN
src/assets/sounds/battle/ship-change.wav
Normal file
BIN
src/assets/sounds/battle/ship-change.wav
Normal file
Binary file not shown.
|
@ -10,7 +10,7 @@ module SpaceTac.View {
|
|||
this.preloadBar.position.set((1280 - this.preloadBar.width) / 2, (720 - this.preloadBar.height) / 2);
|
||||
this.load.setPreloadSprite(this.preloadBar);
|
||||
|
||||
// Load assets
|
||||
// Load images
|
||||
this.loadImage("battle/waiting.png");
|
||||
this.loadImage("battle/shiplist-base.png");
|
||||
this.loadImage("battle/shiplist-normal.png");
|
||||
|
@ -32,6 +32,9 @@ module SpaceTac.View {
|
|||
this.loadImage("ship/scout/portrait.png");
|
||||
this.loadImage("common/standard-bar-background.png");
|
||||
this.loadImage("common/standard-bar-foreground.png");
|
||||
|
||||
// Load sounds
|
||||
this.loadSound("battle/ship-change.wav");
|
||||
}
|
||||
|
||||
create() {
|
||||
|
@ -41,5 +44,10 @@ module SpaceTac.View {
|
|||
private loadImage(path: string) {
|
||||
this.load.image(path.replace(/\//g, "-").replace(".png", "").replace(".jpg", ""), "assets/images/" + path);
|
||||
}
|
||||
|
||||
private loadSound(path: string) {
|
||||
var key = path.replace(/\//g, "-").replace(".wav", "");
|
||||
this.load.audio(key, "assets/sounds/" + path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,8 @@ module SpaceTac.View {
|
|||
arena_ship.setPlaying(true);
|
||||
}
|
||||
this.playing = arena_ship;
|
||||
|
||||
Sound.playOnce(this.game, "battle-ship-change");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
src/scripts/view/common/Sound.ts
Normal file
14
src/scripts/view/common/Sound.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
module SpaceTac.View {
|
||||
"use strict";
|
||||
|
||||
// Utility functions for sounds
|
||||
export class Sound {
|
||||
|
||||
// Play a ponctual sound
|
||||
static playOnce(game: Phaser.Game, key: string): void {
|
||||
if (game.sound.context) {
|
||||
game.sound.play("battle-ship-change");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue