fix key space cool time
This commit is contained in:
@@ -49,6 +49,7 @@ export default function App() {
|
||||
setAnimState({ name, count: countRef.current });
|
||||
}, []);
|
||||
|
||||
const actionCoolRef = useRef(0);
|
||||
const doSkillRef = useRef(null);
|
||||
|
||||
const handleKey = useCallback((e) => {
|
||||
@@ -58,6 +59,9 @@ export default function App() {
|
||||
}
|
||||
if (e.code === 'Space') {
|
||||
e.preventDefault();
|
||||
const now = Date.now();
|
||||
if (now - actionCoolRef.current < 3000) return;
|
||||
actionCoolRef.current = now;
|
||||
const idx = actionIndexRef.current;
|
||||
const anim = ACTION_SEQUENCE[idx % ACTION_SEQUENCE.length];
|
||||
playAnim(anim);
|
||||
|
||||
Reference in New Issue
Block a user