diff --git a/apps/client/src/scenes/game/GameScene.tsx b/apps/client/src/scenes/game/GameScene.tsx index 8bd7e4e..5fbf5c2 100644 --- a/apps/client/src/scenes/game/GameScene.tsx +++ b/apps/client/src/scenes/game/GameScene.tsx @@ -75,7 +75,7 @@ {/* UI 配置領域 */}
{ + onInput={(x, y) => { // ジョイスティックの入力を毎フレーム Manager に渡す gameManagerRef.current?.setJoystickInput(x, y); }} diff --git a/apps/client/src/scenes/game/input/joystick/Joystick.tsx b/apps/client/src/scenes/game/input/joystick/Joystick.tsx index b8d2ea3..83a3692 100644 --- a/apps/client/src/scenes/game/input/joystick/Joystick.tsx +++ b/apps/client/src/scenes/game/input/joystick/Joystick.tsx @@ -3,12 +3,12 @@ export { MAX_DIST } from "./useJoystick"; type Props = { - onMove: (moveX: number, moveY: number) => void; + onInput: (moveX: number, moveY: number) => void; }; -export const Joystick = ({ onMove }: Props) => { +export const Joystick = ({ onInput }: Props) => { const { isMoving, basePos, stickPos, handleStart, handleMove, handleEnd } = - useJoystick({ onMove }); + useJoystick({ onInput }); return (
void; + onInput: (moveX: number, moveY: number) => void; maxDist?: number; }; @@ -29,7 +29,7 @@ return { x: e.clientX, y: e.clientY }; }; -export const useJoystick = ({ onMove, maxDist }: Props): UseJoystickReturn => { +export const useJoystick = ({ onInput, maxDist }: Props): UseJoystickReturn => { const [isMoving, setIsMoving] = useState(false); const [basePos, setBasePos] = useState({ x: 0, y: 0 }); const [stickPos, setStickPos] = useState({ x: 0, y: 0 }); @@ -62,16 +62,16 @@ const normalizedY = offsetY / limit; setStickPos({ x: offsetX, y: offsetY }); - onMove(normalizedX, normalizedY); + onInput(normalizedX, normalizedY); }, - [isMoving, basePos.x, basePos.y, limit, onMove] + [isMoving, basePos.x, basePos.y, limit, onInput] ); const handleEnd = useCallback(() => { setIsMoving(false); setStickPos({ x: 0, y: 0 }); - onMove(0, 0); - }, [onMove]); + onInput(0, 0); + }, [onInput]); return { isMoving, basePos, stickPos, handleStart, handleMove, handleEnd }; };