/** * 暂停游戏类(暂停继续游戏) * @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); };