Browse Source

fix:暂停按钮切换

master
wally 4 years ago
parent
commit
e0180ebb42
  1. 14
      src/classes/suspend.js
  2. 1
      src/custom.js
  3. 3
      src/message.js
  4. 2
      src/test.js

14
src/classes/suspend.js

@ -27,14 +27,24 @@ Suspend.prototype.suspendGame = function () {
suspend.x = 50; suspend.x = 50;
suspend.y = lib.properties.height - 100; suspend.y = lib.properties.height - 100;
this.suspend = suspend; this.suspend = suspend;
const _this = this;
// 继续游戏 // 继续游戏
this.suspend.addEventListener( this.suspend.addEventListener(
'click', 'click',
function () { function () {
stage.removeChild(suspend); _this.hide();
continueMessage(); continueMessage();
}, },
false, 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);
}; };

1
src/custom.js

@ -28,6 +28,7 @@ function initStage(lib) {
Level.of(2); // 游戏难度级别 Level.of(2); // 游戏难度级别
Back.of(); // 返回按钮 Back.of(); // 返回按钮
isHash(); isHash();
window.suspend = Suspend.of();
} }
// 游戏结束 显示结束得分面板 // 游戏结束 显示结束得分面板

3
src/message.js

@ -55,13 +55,14 @@ window.addEventListener(
function pauseGame(data) { function pauseGame(data) {
if (state !== 1) return; if (state !== 1) return;
state = data.status; state = data.status;
Suspend.of(); window.suspend.show();
window.timeInstance.pause(); window.timeInstance.pause();
} }
function continueGame(data) { function continueGame(data) {
if (state !== 3) return; if (state !== 3) return;
state = data.status; state = data.status;
window.suspend.hide();
window.timeInstance.start(); window.timeInstance.start();
} }

2
src/test.js

@ -51,7 +51,7 @@ function addHash() {
function test() { function test() {
document.addEventListener('click', () => { document.addEventListener('click', () => {
if (isDemo) return; if (!isDemo) return;
main.play(0); main.play(0);
}); });
} }

Loading…
Cancel
Save