save code

This commit is contained in:
xsl
2026-05-24 12:35:35 +08:00
parent af3a23520d
commit b3384499e3
6 changed files with 121 additions and 167 deletions
+15 -12
View File
@@ -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 });
// 防止页面滚动/缩放