From e0180ebb426b5794b0ec7d2a4242eb946c38333a Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Thu, 30 Sep 2021 09:34:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=9A=82=E5=81=9C=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/suspend.js | 14 ++++++++++++-- src/custom.js | 1 + src/message.js | 3 ++- src/test.js | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/classes/suspend.js b/src/classes/suspend.js index c33abb5..4102677 100644 --- a/src/classes/suspend.js +++ b/src/classes/suspend.js @@ -27,14 +27,24 @@ Suspend.prototype.suspendGame = function () { suspend.x = 50; suspend.y = lib.properties.height - 100; this.suspend = suspend; + const _this = this; // 继续游戏 this.suspend.addEventListener( 'click', function () { - stage.removeChild(suspend); + _this.hide(); continueMessage(); }, false, ); - stage.addChild(suspend); + // stage.addChild(this.suspend); + // stage.removeChild(this.suspend); +}; + +Suspend.prototype.hide = function () { + stage.removeChild(this.suspend); +}; + +Suspend.prototype.show = function () { + stage.addChild(this.suspend); }; diff --git a/src/custom.js b/src/custom.js index 4820d49..66e95a7 100644 --- a/src/custom.js +++ b/src/custom.js @@ -28,6 +28,7 @@ function initStage(lib) { Level.of(2); // 游戏难度级别 Back.of(); // 返回按钮 isHash(); + window.suspend = Suspend.of(); } // 游戏结束 显示结束得分面板 diff --git a/src/message.js b/src/message.js index 82c98dc..8154b90 100644 --- a/src/message.js +++ b/src/message.js @@ -55,13 +55,14 @@ window.addEventListener( function pauseGame(data) { if (state !== 1) return; state = data.status; - Suspend.of(); + window.suspend.show(); window.timeInstance.pause(); } function continueGame(data) { if (state !== 3) return; state = data.status; + window.suspend.hide(); window.timeInstance.start(); } diff --git a/src/test.js b/src/test.js index 00ca2bc..5b69b21 100644 --- a/src/test.js +++ b/src/test.js @@ -51,7 +51,7 @@ function addHash() { function test() { document.addEventListener('click', () => { - if (isDemo) return; + if (!isDemo) return; main.play(0); }); }