|
@ -26,11 +26,16 @@ function Main(endCallback, max) { |
|
|
* @param {function} endCallback 游戏结束的回调函数 |
|
|
* @param {function} endCallback 游戏结束的回调函数 |
|
|
* @param {number} max 最多运动次数 |
|
|
* @param {number} max 最多运动次数 |
|
|
*/ |
|
|
*/ |
|
|
Main.of = function (endCallback, max = config.times) { |
|
|
Main.of = (function () { |
|
|
const instance = new Main(endCallback, max); |
|
|
let instance = null; |
|
|
instance.init(); |
|
|
return function (endCallback, max = config.times) { |
|
|
return instance; |
|
|
if (!instance) { |
|
|
}; |
|
|
instance = new Main(endCallback, max); |
|
|
|
|
|
} |
|
|
|
|
|
instance.init(); |
|
|
|
|
|
return instance; |
|
|
|
|
|
}; |
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
// 初始方法
|
|
|
// 初始方法
|
|
|
Main.prototype.init = function () { |
|
|
Main.prototype.init = function () { |
|
@ -67,5 +72,7 @@ Main.prototype.computeScore = function (times, direction = 0) { |
|
|
const directionTarget = config.config.scores.find(item => item.direction === direction); |
|
|
const directionTarget = config.config.scores.find(item => item.direction === direction); |
|
|
config.currentTimes = times; |
|
|
config.currentTimes = times; |
|
|
config.currentScore += directionTarget.score; |
|
|
config.currentScore += directionTarget.score; |
|
|
sendMessage({ event: 'play', data: { currentTimes: times, currentScore: config.currentScore } }); |
|
|
if (config.mode === 0) { |
|
|
|
|
|
sendMessage({ event: 'play', data: { currentTimes: times, currentScore: config.currentScore } }); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|