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); }); }