fix: 按键移动不连贯

This commit is contained in:
AncTe committed 2024-11-20 22:33:18 +08:00
1 parent 203fde1fbc
commit a0f51092e2
2 files changed
+2 -1

No files matched your search

+1
View File
@@ -57,6 +57,7 @@ export class HeroKeyMover {
}
private onPressKey = (code: KeyCode) => {
if (core.isReplaying()) return;
if (code === this.hotkeyData.left.key) this.press('left');
else if (code === this.hotkeyData.right.key) this.press('right');
else if (code === this.hotkeyData.up.key) this.press('up');
+1 -1
View File
@@ -229,8 +229,8 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
if (!this.enabled) return false;
const when = this.conditionMap.get(this.scope)!;
if (type === 'up') this.checkPressEnd(key);
else if (type === 'down') this.checkPress(key);
if (!when()) return false;
if (type === 'down') this.checkPress(key);
const toEmit = this.keyMap.get(key);
if (!toEmit) return false;