1
0
Fork 0

Added ship change sound

This commit is contained in:
Michaël Lemaire 2015-02-16 01:00:00 +01:00
parent 97771a9b0a
commit 7ad81617f3
4 changed files with 25 additions and 1 deletions

Binary file not shown.

View file

@ -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);
}
}
}

View file

@ -104,6 +104,8 @@ module SpaceTac.View {
arena_ship.setPlaying(true);
}
this.playing = arena_ship;
Sound.playOnce(this.game, "battle-ship-change");
}
}
}

View 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");
}
}
}
}