save code
This commit is contained in:
+15
-12
@@ -31,23 +31,26 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// 防止双重启动
|
||||
let _started = false;
|
||||
function startGame(el) {
|
||||
if (_started) return;
|
||||
_started = true;
|
||||
el.style.transition = 'opacity 0.8s';
|
||||
el.style.opacity = '0';
|
||||
setTimeout(() => { el.style.display = 'none'; }, 800);
|
||||
main();
|
||||
}
|
||||
|
||||
// 触摸启动(手机)
|
||||
document.getElementById('start').addEventListener('touchend', async function onStart(e) {
|
||||
document.getElementById('start').addEventListener('touchend', function(e) {
|
||||
e.preventDefault();
|
||||
this.removeEventListener('touchend', onStart);
|
||||
this.style.transition = 'opacity 0.8s';
|
||||
this.style.opacity = '0';
|
||||
setTimeout(() => { this.style.display = 'none'; }, 800);
|
||||
await main();
|
||||
startGame(this);
|
||||
}, { once: true });
|
||||
|
||||
// 鼠标点击(电脑调试)
|
||||
document.getElementById('start').addEventListener('click', async function onClick() {
|
||||
this.removeEventListener('click', onClick);
|
||||
this.style.transition = 'opacity 0.8s';
|
||||
this.style.opacity = '0';
|
||||
setTimeout(() => { this.style.display = 'none'; }, 800);
|
||||
await main();
|
||||
document.getElementById('start').addEventListener('click', function() {
|
||||
startGame(this);
|
||||
}, { once: true });
|
||||
|
||||
// 防止页面滚动/缩放
|
||||
|
||||
Reference in New Issue
Block a user