import { useComputed } from '@preact/signals'; import { createGameHost, type GameModule } from 'boardgame-core'; import Phaser from 'phaser'; import { h } from 'preact'; import { PhaserGame, PhaserScene } from 'boardgame-phaser'; export default function App>(props: { gameModule: GameModule, gameScene: { new(): Phaser.Scene } }) { const gameHost = useComputed(() => { const gameHost = createGameHost(props.gameModule); return { gameHost }; }); const scene = useComputed(() => new props.gameScene()); const handleReset = async () => { const result = await gameHost.value.gameHost.start(); console.log('Game finished!', result); }; const label = useComputed(() => gameHost.value.gameHost.status.value === 'running' ? '重新开始' : '开始游戏' ); // Phaser 画布配置 const phaserConfig = { type: Phaser.AUTO, width: 800, height: 700, backgroundColor: '#111827', }; return (
{/* Phaser 游戏场景 */}
{/* 底部控制栏 */}
⚔️ Regicide - 击败所有12个敌人
); }