diff --git a/index.js b/index.js index 7b60ba4..d70e34c 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,7 @@ const obj = { btnAgain: null, // 再玩一次的按钮 bgModalBegin: null, // 开始倒计时面板 countTimer: null, // 开始游戏的倒计时的 计时器id + initCount: 5, // 默认倒计时时长 count: 5, // 开始游戏时的倒计时 music: { bgm: null, // 背景音乐 @@ -134,7 +135,7 @@ function initBeginCount() { stage.removeChild(obj.btnBegin); // 移除开始游戏的按钮 const startTime = +gameInfo.startTime; - const endCountTime = startTime + obj.count * 1000; + const endCountTime = startTime + obj.initCount * 1000; obj.count = Math.floor((endCountTime - Date.now()) / 1000); changeBeginTime(obj.count); // 开始开始游戏的 倒计时 @@ -426,7 +427,7 @@ function sendEndRequest() { // 处理倒计时 function interval() { if (obj.timerId) return; - const endTime = +gameInfo.startTime + 10 * 1000 + +gameInfo.duration; + const endTime = +gameInfo.startTime + obj.initCount * 1000 + +gameInfo.duration; obj.timerId = setInterval(function () { if (obj.totalTime === 0) { gameOver();