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.
66 lines
1.4 KiB
66 lines
1.4 KiB
4 years ago
|
/**
|
||
|
* 游戏结束
|
||
|
* @param {number} score 最终得分
|
||
|
*
|
||
|
* @property {object} lib 资源对象
|
||
|
* @property {number} score 最终得分
|
||
|
* @property {object} modal 面板元素对象
|
||
|
* @property {object} text 文本元素对象
|
||
|
*/
|
||
|
function End(score) {
|
||
|
this.lib = library;
|
||
|
|
||
|
this.score = score;
|
||
|
|
||
|
this.modal = null;
|
||
|
this.text = null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 静态方法 封装new init 返回实例
|
||
|
* @param {number} score 最终得分
|
||
|
* @returns
|
||
|
*/
|
||
|
End.of = (function () {
|
||
|
let instance = null;
|
||
|
return function (score) {
|
||
|
if (!instance) {
|
||
|
instance = new End(score);
|
||
|
}
|
||
|
instance.init();
|
||
|
return instance;
|
||
|
};
|
||
|
})();
|
||
|
|
||
|
// 初始化
|
||
|
End.prototype.init = function () {
|
||
|
this.renderModal();
|
||
|
this.renderText(this.score);
|
||
|
Again.of();
|
||
|
};
|
||
|
|
||
|
// 渲染背景面板
|
||
|
End.prototype.renderModal = function () {
|
||
|
const lib = this.lib;
|
||
|
const target = new lib.bgModalEnd();
|
||
|
target.x = lib.properties.width / 2;
|
||
|
target.y = lib.properties.height / 2;
|
||
|
this.modal = target;
|
||
|
stage.addChild(target);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* 渲染得分文本对象
|
||
|
* @param {number} score 最终得分
|
||
|
*/
|
||
|
End.prototype.renderText = function (score) {
|
||
|
const lib = this.lib;
|
||
|
const target = new createjs.Text(score, 'bold 100px Arial', '#793b18');
|
||
|
target.x = lib.properties.width / 2;
|
||
|
target.y = lib.properties.height / 2 + 70;
|
||
|
target.textAlign = 'center';
|
||
|
target.textBaseline = 'alphabetic';
|
||
|
this.text = target;
|
||
|
stage.addChild(target);
|
||
|
};
|