From 849e23ee5d99ca4745dbf825877bc3a9328ca8bf Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Tue, 12 May 2015 11:05:52 +0200 Subject: [PATCH] Improved sound managment --- static/js/prototype/Coin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/static/js/prototype/Coin.js b/static/js/prototype/Coin.js index 1f97938..38ee8e1 100644 --- a/static/js/prototype/Coin.js +++ b/static/js/prototype/Coin.js @@ -42,14 +42,18 @@ Coin.prototype.get = function() { Coin.total ++; Coin.nextSound.play(); if (Coin.total === 9) { - var audio = new Audio('/static/data/music/starappears.mp3'); - audio.play(); + // You got the last coin + setTimeout(function() {Coin.lastSound.play();}, Coin.nextSound.duration + 1000); } else { 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.BASIC_MESH = null;