From bfb2113b8129db1ab983fe84e0cfccebf882fda4 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Wed, 28 Jul 2021 18:50:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=80=92=E8=AE=A1=E6=97=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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();