Add sound effects

master
Skylar Ittner 7 years ago
parent 6a5fa9b4f8
commit 4dfbc2cda2

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -20,8 +20,10 @@ var audio_stay_stopped = false;
var audio_doneplaying = true;
var audio_isplaying = false;
var audio;
var sound;
var MUSIC_DIR = getWwwFolderPath() + "assets/audio/";
var SOUND_DIR = getWwwFolderPath() + "assets/sound/";
function queuesong(song) {
if (audio_isplaying) {
@ -61,6 +63,14 @@ function playAudio() {
audio.play({playAudioWhenScreenIsLocked: false});
}
function playSound(soundname) {
if (localStorage.getItem("sounds") === "mute") {
return;
}
sound = new Media(SOUND_DIR + soundname + ".mp3", null, null, null);
sound.play({playAudioWhenScreenIsLocked: false});
}
document.addEventListener("pause", function () {
audio.pause();
audio_doneplaying = false;

@ -38,10 +38,12 @@ function buycoins(productId) {
});
})
.then(function () {
playSound("coin");
showSuccessMessage("Thanks for your purchase!");
refreshcoins();
})
.catch(function (err) {
playSound("error");
console.log("Error: " + err.message);
showErrorMessage("Error: " + err.message);
});
@ -67,10 +69,12 @@ function buycoins(productId) {
});
})
.then(function () {
playSound("coin");
showSuccessMessage("Thanks for your purchase!");
refreshcoins();
})
.catch(function (err) {
playSound("error");
console.log("Error: " + err.message);
showErrorMessage("Error: " + err.message);
});
@ -87,8 +91,10 @@ function buyitem(id, cost) {
lang: USER_LANGUAGE
}, function (data) {
if (data.status == 'OK') {
playSound("coin");
showSuccessMessage(data.message);
} else {
playSound("error");
showErrorMessage(data.message);
}
loadstorefront();

@ -61,6 +61,7 @@
content = "";
}
if (content == '') {
playSound("error");
showErrorMessage("There is nobody nearby to give an item to.");
} else {
$('#nearby-players-dropdown').html(content);
@ -84,6 +85,7 @@
syncStats();
showSuccessMessage("Transferred!");
} else {
playSound("error");
showErrorMessage(data.message);
}
}).fail(function () {
@ -101,6 +103,7 @@
loadinventory();
syncStats();
} else {
playSound("error");
showErrorMessage(data.message);
}
}).fail(function () {

@ -184,16 +184,22 @@
case 3:
$('#place-log').prepend("Attacking....<br />");
}
if (data.levelup === true) {
playSound("levelup");
} else {
playSound("woosh");
}
resync();
} else {
playSound("error");
$('#capturebtn').text(data.message);
$('#capturebtn').removeClass('btn-primary');
$('#capturebtn').addClass('btn-warning');
$('#place-log').prepend(data.message + "<br />");
resync();
}
//alert(data.message);
}).fail(function () {
playSound("error");
$('#capturebtn').text("Try that again.");
$('#capturebtn').removeClass('btn-primary');
$('#capturebtn').addClass('btn-warning');
@ -223,7 +229,13 @@
case 3:
$('#place-log').prepend("Recharging....<br />");
}
if (data.levelup === true) {
playSound("levelup");
} else {
playSound("refill");
}
} else {
playSound("error");
$('#refillbtn').text(data.message);
$('#refillbtn').removeClass('btn-primary');
$('#refillbtn').addClass('btn-warning');
@ -231,6 +243,7 @@
}
resync();
}).fail(function () {
playSound("error");
$('#refillbtn').text("Try that again.");
$('#refillbtn').removeClass('btn-primary');
$('#refillbtn').addClass('btn-warning');
@ -251,16 +264,22 @@
if (data.status === 'OK') {
$('#capturebtn').text(data.message);
$('#place-log').prepend("Claimed!<br />");
if (data.levelup === true) {
playSound("levelup");
} else {
playSound("claim");
}
resync();
} else {
playSound("error");
$('#capturebtn').text(data.message);
$('#capturebtn').removeClass('btn-primary');
$('#capturebtn').addClass('btn-warning');
$('#place-log').prepend(data.message + "<br />");
resync();
}
//alert(data.message);
}).fail(function () {
playSound("error");
$('#capturebtn').text("Try that again.");
$('#capturebtn').removeClass('btn-primary');
$('#capturebtn').addClass('btn-warning');

@ -29,6 +29,9 @@
<div class="list-group-item" onclick="toggleMusic()">
Turn music <span id="toggle-music-onoff-label">off</span>
</div>
<div class="list-group-item" onclick="toggleSounds()">
Turn sounds <span id="toggle-sounds-onoff-label">off</span>
</div>
<div class='list-group-item' onclick='openscreen("munzeelink")'>
Link with Munzee account
<br />
@ -54,6 +57,11 @@
} else {
$('#toggle-music-onoff-label').text("off");
}
if (localStorage.getItem("sounds") == "mute") {
$('#toggle-sounds-onoff-label').text("on");
} else {
$('#toggle-sounds-onoff-label').text("off");
}
}
function toggleMusic() {
@ -66,6 +74,15 @@
}
loadToggles();
}
function toggleSounds() {
if (localStorage.getItem("sounds") == "mute") {
localStorage.setItem("sounds", "");
} else {
localStorage.setItem("sounds", "mute");
}
loadToggles();
}
loadToggles();