Improved sound managment

This commit is contained in:
Thomas FORGIONE 2015-05-12 11:05:52 +02:00
parent 1d6e12611a
commit 849e23ee5d
1 changed files with 6 additions and 2 deletions

View File

@ -42,14 +42,18 @@ Coin.prototype.get = function() {
Coin.total ++; Coin.total ++;
Coin.nextSound.play(); Coin.nextSound.play();
if (Coin.total === 9) { if (Coin.total === 9) {
var audio = new Audio('/static/data/music/starappears.mp3'); // You got the last coin
audio.play(); setTimeout(function() {Coin.lastSound.play();}, Coin.nextSound.duration + 1000);
} else { } else {
Coin.nextSound = new Audio('/static/data/music/redcoins/' + Coin.total + '.mp3'); Coin.nextSound = new Audio('/static/data/music/redcoins/' + Coin.total + '.mp3');
Coin.nextSound.preload = "auto";
} }
} }
} }
Coin.lastSound = new Audio('/static/data/music/starappears.mp3');
Coin.lastSound.preload = "auto";
Coin.total = 1; Coin.total = 1;
Coin.BASIC_MESH = null; Coin.BASIC_MESH = null;