Skip to content

Commit

Permalink
fixed on the audio detail
Browse files Browse the repository at this point in the history
  • Loading branch information
jygao committed Sep 22, 2018
1 parent 407c940 commit edc8c8f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ function hasPassAllLevel(){
return gameObj.curLevel>=GAME_CONST.levels;
}

updateLevelConfig();
updateLevelConfig();
12 changes: 9 additions & 3 deletions js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ function main() {

clickAudio = document.createElement("audio");
clickAudio.src="sound/click.wav";
clickAudio.loop = false;
document.body.appendChild(clickAudio);

linkAudio = document.createElement("audio");
linkAudio.src="sound/link.wav";
linkAudio.loop = false;
document.body.appendChild(linkAudio);


Expand Down Expand Up @@ -285,6 +283,7 @@ function resetGame() {
remainRefreshTime = gameObj.levelConfig.refresh;
remainTipTime = gameObj.levelConfig.prompt;
remainSec = gameObj.levelConfig.time;
bgAudio.play();

resetAutoTip();

Expand Down Expand Up @@ -398,6 +397,7 @@ var Card ={
return card.initY;
}
card.setSelected = function(){
clickAudio.load();
clickAudio.play();
card.divContainer.appendChild(card.chooseLightIamge);
card.chooseLightIamge.style.position= "absolute";
Expand Down Expand Up @@ -450,7 +450,7 @@ var Card ={
}
}
}

card.changeTypeAndUpdateImage = function (newType) {
// console.log(card.x+":"+card.y);
if(card.image!=null){
Expand Down Expand Up @@ -538,6 +538,7 @@ function onClickCard(card) {
secondClickCard = null;
return;
}
linkAudio.load();
linkAudio.play();
resetAutoTip();
isMissing = true;
Expand Down Expand Up @@ -602,6 +603,7 @@ function addExtraTotalScore() {

function checkIsFinished() {
if(totalCanChooseCardNum<=0){
bgAudio.pause();
stopGameTime();
addExtraTotalScore();
sendGateFinishMsg();
Expand Down Expand Up @@ -668,8 +670,10 @@ function onPopUpQuitConfirmDialog() {
sendPlayOrStopMsg(false);
isGameTimeCounting = false;
autoTimeCounting = false;
bgAudio.pause();
showQuitConfirmDialog({
"onContinueGame":function () {
bgAudio.play();
sendPlayOrStopMsg(true);
isGameTimeCounting = true;
},
Expand All @@ -681,10 +685,12 @@ function onPopUpStopDialog() {
sendPlayOrStopMsg(false);
isGameTimeCounting = false;
autoTimeCounting = false;
bgAudio.pause();
showStopDialog({
"onContinueGame":function () {
sendPlayOrStopMsg(true);
isGameTimeCounting = true;
bgAudio.play();
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions js/js2as.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if(parent){
function localCloseVBox() {
if(parent&&parent.closeVBox){
parent.closeVBox();
}else{
window.location.reload();
}
}

Expand Down
8 changes: 5 additions & 3 deletions js/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

var bgAudio;
function onStart() {
var container = document.getElementById("container");
document.body.removeChild(container);
Expand All @@ -19,9 +19,11 @@ function onStart() {
canvas.style.zIndex = "2";
document.body.appendChild(canvas);

var bgAudio = document.createElement("audio");
bgAudio = document.createElement("audio");
bgAudio.src="sound/bg.mp3";
bgAudio.autoplay ="autoplay";
bgAudio.loop = "loop";
bgAudio.volume = 0.05;
document.body.appendChild(bgAudio);

main();
Expand All @@ -42,4 +44,4 @@ function onStart() {
}
function onClose() {
localCloseVBox();
}
}

0 comments on commit edc8c8f

Please sign in to comment.