Browse Source

完善界面

master
song 4 years ago
parent
commit
5c8e07efca
  1. 4
      src/classes/again.js
  2. 4
      src/classes/end.js
  3. 11
      src/classes/level.js
  4. 2
      src/custom.js
  5. 16
      src/message.js

4
src/classes/again.js

@ -35,7 +35,11 @@ Again.prototype.showAgainBtn = function () {
this.btnAgain.addEventListener( this.btnAgain.addEventListener(
'click', 'click',
function () { function () {
if (config.mode === 0) {
againMessage();
} else {
location.reload(); location.reload();
}
}, },
false, false,
); );

4
src/classes/end.js

@ -23,9 +23,9 @@ function End(score) {
*/ */
End.of = (function () { End.of = (function () {
let instance = null; let instance = null;
return function () { return function (score) {
if (!instance) { if (!instance) {
instance = new End(); instance = new End(score);
} }
instance.init(); instance.init();
return instance; return instance;

11
src/classes/level.js

@ -2,7 +2,7 @@
* 难度等级类 * 难度等级类
* @param {number} level 等级数字代码 * @param {number} level 等级数字代码
*/ */
function Level(level = config.level || 1) { function Level(level) {
this.lib = library; this.lib = library;
this.level = level; this.level = level;
@ -13,16 +13,11 @@ function Level(level = config.level || 1) {
* @param {number} level 等级数值 * @param {number} level 等级数值
* @returns * @returns
*/ */
Level.of = (function () { Level.of = function (level) {
let instance = null; const instance = new Level(level);
return function (level) {
if (!instance) {
instance = new Level(level);
}
instance.init(); instance.init();
return instance; return instance;
}; };
})();
// 初始化 渲染 // 初始化 渲染
// 更新config中的level属性 // 更新config中的level属性

2
src/custom.js

@ -25,7 +25,7 @@ function initStage(lib) {
window.timeInstance = Time.of(gameOver); // 初始化游戏时间 window.timeInstance = Time.of(gameOver); // 初始化游戏时间
window.soundInstance = Sound.of(); // 初始化音频 window.soundInstance = Sound.of(); // 初始化音频
Level.of(2); // 游戏难度级别 Level.of(config.level); // 游戏难度级别
Back.of(); // 返回按钮 Back.of(); // 返回按钮
isHash(); isHash();
window.suspend = Suspend.of(); window.suspend = Suspend.of();

16
src/message.js

@ -36,8 +36,13 @@ window.addEventListener(
config.mode = game.mode; config.mode = game.mode;
window.timeInstance.setDuration(game.duration); window.timeInstance.setDuration(game.duration);
Level.of(config.level);
if (config.mode === 0) {
// 开始倒计时 // 开始倒计时
Count.of(countOver); Count.of(countOver);
} else {
sevenClick();
}
} }
function playGame(data) { function playGame(data) {
@ -112,3 +117,14 @@ function finishMessage(score, times) {
}; };
sendMessage(data); sendMessage(data);
} }
// 发送再来一次消息
function againMessage() {
const data = {
event: 'again',
data: {
param: {}, // 额外个性化参数
},
};
sendMessage(data);
}

Loading…
Cancel
Save