19 changed files with 2169 additions and 3961 deletions
Binary file not shown.
File diff suppressed because it is too large
Binary file not shown.
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,38 @@ |
|||
/** |
|||
* 再玩一次类 |
|||
* @property {object} lib 库对象 |
|||
* @property {object} btnAgain 面板元素对象 |
|||
*/ |
|||
function Again() { |
|||
this.lib = library; |
|||
|
|||
this.btnAgain = null; |
|||
} |
|||
|
|||
Again.of = function () { |
|||
const instance = new Again(); |
|||
instance.init(); |
|||
return instance; |
|||
}; |
|||
|
|||
// 初始化
|
|||
Again.prototype.init = function () { |
|||
this.showAgainBtn(); |
|||
}; |
|||
|
|||
// 渲染背景面板
|
|||
Again.prototype.showAgainBtn = function () { |
|||
const lib = this.lib; |
|||
const btnAgain = new lib.btnAgain(); |
|||
btnAgain.x = lib.properties.width / 2; |
|||
btnAgain.y = lib.properties.height / 2 + 150; |
|||
this.btnAgain = btnAgain; |
|||
this.btnAgain.addEventListener( |
|||
'click', |
|||
function () { |
|||
location.reload(); |
|||
}, |
|||
false, |
|||
); |
|||
stage.addChild(btnAgain); |
|||
}; |
@ -0,0 +1,41 @@ |
|||
/** |
|||
* 演示模式类 |
|||
* @property {object} lib 库对象 |
|||
* @property {object} stopDemo 面板元素对象 |
|||
*/ |
|||
function Demo() { |
|||
this.lib = library; |
|||
|
|||
this.stopDemo = null; |
|||
} |
|||
|
|||
Demo.of = function () { |
|||
const instance = new Demo(); |
|||
instance.init(); |
|||
return instance; |
|||
}; |
|||
|
|||
// 初始化
|
|||
Demo.prototype.init = function () { |
|||
this.showStopDemo(); |
|||
}; |
|||
|
|||
// 显示演示模式按钮
|
|||
Demo.prototype.showStopDemo = function () { |
|||
const lib = this.lib; |
|||
const stopDemo = new lib.stopDemo(); |
|||
stopDemo.x = 50; |
|||
stopDemo.y = lib.properties.height - 100; |
|||
this.stopDemo = stopDemo; |
|||
// 关闭演示模式
|
|||
this.stopDemo.addEventListener( |
|||
'click', |
|||
function () { |
|||
stage.removeChild(stopDemo); |
|||
location.hash = ''; |
|||
location.reload(); |
|||
}, |
|||
false, |
|||
); |
|||
stage.addChild(stopDemo); |
|||
}; |
@ -0,0 +1,53 @@ |
|||
// 判断是否在演示模式 能否直接开始游戏
|
|||
function isHash() { |
|||
if (location.hash && location.hash === 'p') { |
|||
Demo.of(); |
|||
Count.of(countOver); |
|||
} else { |
|||
// 连点7次触发倒计时
|
|||
startGame(); |
|||
} |
|||
} |
|||
|
|||
function startGame() { |
|||
var count = 0, |
|||
timer; |
|||
document.onclick = function () { |
|||
if (count < 6) { |
|||
if (timer) { |
|||
clearTimeout(timer); |
|||
} |
|||
count++; |
|||
timer = setTimeout(function () { |
|||
count = 0; |
|||
}, 300); |
|||
} else if (count === 6) { |
|||
count = 0; |
|||
clearTimeout(timer); |
|||
sevenClick(); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
function sevenClick() { |
|||
Count.of(countOver); |
|||
addHash(); |
|||
} |
|||
|
|||
// 倒计时结束 开始游戏
|
|||
function countOver() { |
|||
timeInstance.start(); |
|||
} |
|||
|
|||
// 添加hash值
|
|||
function addHash() { |
|||
location.hash = 'p'; |
|||
Demo.of(); |
|||
} |
|||
|
|||
function test() { |
|||
document.addEventListener('click', () => { |
|||
main.play(); |
|||
}); |
|||
} |
|||
test(); |
Loading…
Reference in new issue