fix: 按键移动不连贯

This commit is contained in:
unanmed 2024-11-20 22:33:18 +08:00
parent 203fde1fbc
commit a0f51092e2
2 changed files with 2 additions and 1 deletions

View File

@ -57,6 +57,7 @@ export class HeroKeyMover {
} }
private onPressKey = (code: KeyCode) => { private onPressKey = (code: KeyCode) => {
if (core.isReplaying()) return;
if (code === this.hotkeyData.left.key) this.press('left'); if (code === this.hotkeyData.left.key) this.press('left');
else if (code === this.hotkeyData.right.key) this.press('right'); else if (code === this.hotkeyData.right.key) this.press('right');
else if (code === this.hotkeyData.up.key) this.press('up'); else if (code === this.hotkeyData.up.key) this.press('up');

View File

@ -229,8 +229,8 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
if (!this.enabled) return false; if (!this.enabled) return false;
const when = this.conditionMap.get(this.scope)!; const when = this.conditionMap.get(this.scope)!;
if (type === 'up') this.checkPressEnd(key); if (type === 'up') this.checkPressEnd(key);
else if (type === 'down') this.checkPress(key);
if (!when()) return false; if (!when()) return false;
if (type === 'down') this.checkPress(key);
const toEmit = this.keyMap.get(key); const toEmit = this.keyMap.get(key);
if (!toEmit) return false; if (!toEmit) return false;