You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
/**
|
|
* 暂停游戏类(暂停继续游戏)
|
|
* @property {object} lib 库对象
|
|
* @property {object} suspend 面板元素对象
|
|
*/
|
|
function Suspend() {
|
|
this.lib = library;
|
|
|
|
this.suspend = null;
|
|
}
|
|
|
|
Suspend.of = (function () {
|
|
let instance = null;
|
|
return function () {
|
|
if (!instance) {
|
|
instance = new Suspend();
|
|
}
|
|
instance.init();
|
|
return instance;
|
|
};
|
|
})();
|
|
|
|
// 初始化
|
|
Suspend.prototype.init = function () {
|
|
this.suspendGame();
|
|
};
|
|
|
|
// 暂停游戏按钮
|
|
Suspend.prototype.suspendGame = function () {
|
|
// const lib = this.lib;
|
|
const suspend = new this.lib.suspend();
|
|
suspend.x = 50;
|
|
suspend.y = this.lib.properties.height - 100;
|
|
this.suspend = suspend;
|
|
const _this = this;
|
|
// 继续游戏
|
|
this.suspend.addEventListener(
|
|
'click',
|
|
function () {
|
|
_this.hide();
|
|
continueMessage();
|
|
},
|
|
false,
|
|
);
|
|
// stage.addChild(this.suspend);
|
|
// stage.removeChild(this.suspend);
|
|
};
|
|
|
|
Suspend.prototype.hide = function () {
|
|
stage.removeChild(this.suspend);
|
|
};
|
|
|
|
Suspend.prototype.show = function () {
|
|
stage.addChild(this.suspend);
|
|
};
|
|
|