diff --git a/apps/client/src/scenes/game/GameScene.tsx b/apps/client/src/scenes/game/GameScene.tsx index 5fbf5c2..6dce426 100644 --- a/apps/client/src/scenes/game/GameScene.tsx +++ b/apps/client/src/scenes/game/GameScene.tsx @@ -1,8 +1,9 @@ import { useEffect, useRef, useState } from "react"; -import { Joystick } from "./input/joystick/Joystick"; import { GameManager } from "./GameManager"; +import { GameView } from "./GameView"; import { config } from "@repo/shared"; +/** GameScene の入力プロパティ */ interface GameSceneProps { myId: string | null; } @@ -33,7 +34,7 @@ const manager = new GameManager(pixiContainerRef.current, myId); manager.init(); - // 参照を保持(ジョイスティック入力を渡すため) + // 参照を保持(入力を渡すため) gameManagerRef.current = manager; // 描画用のタイマーループ (100msごとに更新して滑らかにする) @@ -53,34 +54,12 @@ }, [myId]); return ( -
- {/* タイマーUIの表示 */} -
- {timeLeft} -
- - {/* PixiJS Canvas 配置領域 */} -
- - {/* UI 配置領域 */} -
- { - // ジョイスティックの入力を毎フレーム Manager に渡す - gameManagerRef.current?.setJoystickInput(x, y); - }} - /> -
-
+ { + gameManagerRef.current?.setJoystickInput(x, y); + }} + /> ); } \ No newline at end of file diff --git a/apps/client/src/scenes/game/GameView.tsx b/apps/client/src/scenes/game/GameView.tsx new file mode 100644 index 0000000..a1c5732 --- /dev/null +++ b/apps/client/src/scenes/game/GameView.tsx @@ -0,0 +1,58 @@ +/** + * GameView + * ゲーム画面の描画専用コンポーネント + * タイマー表示,PixiJSの描画領域,入力UIの配置のみを担当する + */ +import { Joystick } from "./input/joystick/Joystick"; + +/** 表示と入力に必要なプロパティ */ +type Props = { + timeLeft: string; + pixiContainerRef: React.RefObject; + onInput: (x: number, y: number) => void; +}; + +/** 画面描画と入力UIをまとめて描画する */ +export const GameView = ({ timeLeft, pixiContainerRef, onInput }: Props) => { + return ( +
+ {/* タイマーUIの表示 */} +
+ {timeLeft} +
+ + {/* PixiJS Canvas 配置領域 */} +
+ + {/* UI 配置領域 */} +
+ +
+
+ ); +};