Files
xsl 866f363591 项目整理:重写主文档、归档过时文档、清理死代码、新增音频制作手册
文档整理:
- 重写 game/操作说明.md 为项目主文档(6游戏/6手势/旁白/模型生成音频/TTS两步流程)
- 归档过时文档至 other_docs/(林夏原始设计、旧执行文档)
- 新增 docs/音频制作执行手册.md(从零制作游戏音频的完整流程)
- docs/ 下保留旁白音色提示词、音频脚本

代码清理:
- 删除旧架构死代码: story.js / gestures.js / profile.js
- 删除耦合旧架构的过时测试目录 game/tests/

脚本配置修正:
- check_tts_env.sh: 启动脚本路径 AutoVideo → tts-server(实际位置)
- gen_narrator_samples.py: 硬编码地址改为环境变量,默认对齐 tts-server 端口 8000
2026-06-19 22:29:04 +08:00

75 lines
1.8 KiB
JavaScript

// input.js — 输入检测
// 只保留两种操作:单击 / 双击
// 键盘:空格=单击,回车=双击(桌面调试)
class InputDetector {
constructor(el) {
this.el = el;
this.onTap = null;
this.onDoubleTap = null;
this.enabled = false;
this._last = 0;
this._timer = null;
this._WIN = 300; // ms双击判定窗口
this._bindTouch();
this._bindMouse();
this._bindKeyboard();
}
enable() { this.enabled = true; }
disable() { this.enabled = false; }
_fire(e) {
e.preventDefault();
if (!this.enabled) return;
const now = Date.now();
if (now - this._last < this._WIN) {
// 双击
clearTimeout(this._timer);
this._last = 0;
Haptic.confirm();
SFX_UI.skip();
dbg('[input] double-tap');
if (this.onDoubleTap) this.onDoubleTap();
} else {
this._last = now;
this._timer = setTimeout(() => {
this._last = 0;
Haptic.confirm();
SFX_UI.tap();
dbg('[input] tap');
if (this.onTap) this.onTap();
}, this._WIN);
}
}
_bindTouch() {
this.el.addEventListener('touchend', e => this._fire(e), { passive: false });
}
_bindMouse() {
this.el.addEventListener('click', e => this._fire(e));
}
_bindKeyboard() {
document.addEventListener('keydown', e => {
if (!this.enabled) return;
if (e.code === 'Space') {
e.preventDefault();
Haptic.confirm();
SFX_UI.tap();
dbg('[input] tap (kbd)');
if (this.onTap) this.onTap();
} else if (e.code === 'Enter') {
e.preventDefault();
Haptic.confirm();
SFX_UI.skip();
dbg('[input] double-tap (kbd)');
if (this.onDoubleTap) this.onDoubleTap();
}
});
}
}