From edc8c8f9c8a8534e59c5ff1787cff3cabeac26f2 Mon Sep 17 00:00:00 2001 From: jygao Date: Sat, 22 Sep 2018 21:23:56 +0800 Subject: [PATCH] fixed on the audio detail --- js/data.js | 2 +- js/game.js | 12 +++++++++--- js/js2as.js | 2 ++ js/start.js | 8 +++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/js/data.js b/js/data.js index bdb0889..5634420 100644 --- a/js/data.js +++ b/js/data.js @@ -61,4 +61,4 @@ function hasPassAllLevel(){ return gameObj.curLevel>=GAME_CONST.levels; } -updateLevelConfig(); \ No newline at end of file +updateLevelConfig(); diff --git a/js/game.js b/js/game.js index cb72d26..5bf2112 100644 --- a/js/game.js +++ b/js/game.js @@ -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); @@ -285,6 +283,7 @@ function resetGame() { remainRefreshTime = gameObj.levelConfig.refresh; remainTipTime = gameObj.levelConfig.prompt; remainSec = gameObj.levelConfig.time; + bgAudio.play(); resetAutoTip(); @@ -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"; @@ -450,7 +450,7 @@ var Card ={ } } } - + card.changeTypeAndUpdateImage = function (newType) { // console.log(card.x+":"+card.y); if(card.image!=null){ @@ -538,6 +538,7 @@ function onClickCard(card) { secondClickCard = null; return; } + linkAudio.load(); linkAudio.play(); resetAutoTip(); isMissing = true; @@ -602,6 +603,7 @@ function addExtraTotalScore() { function checkIsFinished() { if(totalCanChooseCardNum<=0){ + bgAudio.pause(); stopGameTime(); addExtraTotalScore(); sendGateFinishMsg(); @@ -668,8 +670,10 @@ function onPopUpQuitConfirmDialog() { sendPlayOrStopMsg(false); isGameTimeCounting = false; autoTimeCounting = false; + bgAudio.pause(); showQuitConfirmDialog({ "onContinueGame":function () { + bgAudio.play(); sendPlayOrStopMsg(true); isGameTimeCounting = true; }, @@ -681,10 +685,12 @@ function onPopUpStopDialog() { sendPlayOrStopMsg(false); isGameTimeCounting = false; autoTimeCounting = false; + bgAudio.pause(); showStopDialog({ "onContinueGame":function () { sendPlayOrStopMsg(true); isGameTimeCounting = true; + bgAudio.play(); } }) } diff --git a/js/js2as.js b/js/js2as.js index 5ce2d4e..87af7e8 100644 --- a/js/js2as.js +++ b/js/js2as.js @@ -29,6 +29,8 @@ if(parent){ function localCloseVBox() { if(parent&&parent.closeVBox){ parent.closeVBox(); + }else{ + window.location.reload(); } } diff --git a/js/start.js b/js/start.js index a0d6528..3d5facf 100644 --- a/js/start.js +++ b/js/start.js @@ -1,4 +1,4 @@ - +var bgAudio; function onStart() { var container = document.getElementById("container"); document.body.removeChild(container); @@ -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(); @@ -42,4 +44,4 @@ function onStart() { } function onClose() { localCloseVBox(); -} \ No newline at end of file +}