refactor: api
This commit is contained in:
@@ -86,8 +86,7 @@ export class GameScene extends GameHostScene<TicTacToeState> {
|
||||
}
|
||||
|
||||
private async goToMenu(): Promise<void> {
|
||||
const data = this.initData as unknown as Record<string, unknown>;
|
||||
await this.sceneController.launch('MenuScene', data);
|
||||
await this.sceneController.launch('MenuScene');
|
||||
}
|
||||
|
||||
private setupInput(): void {
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import { createGameHost } from 'boardgame-core';
|
||||
import { h } from 'preact';
|
||||
import { h } from 'preact';
|
||||
import {PhaserGame, PhaserScene } from 'boardgame-phaser';
|
||||
import {MenuScene} from "@/scenes/MenuScene";
|
||||
import {useMemo} from "preact/hooks";
|
||||
import * as gameModule from '../game/tic-tac-toe';
|
||||
import {GameScene} from "@/scenes/GameScene";
|
||||
import {createGameHost} from "boardgame-core";
|
||||
|
||||
export default function App() {
|
||||
|
||||
const gameHost = useMemo(() => {
|
||||
const gameHost = createGameHost(gameModule);
|
||||
return { gameHost };
|
||||
}, []);
|
||||
|
||||
const gameHost = useMemo(() => createGameHost(gameModule), []);
|
||||
const gameScene = useMemo(() => new GameScene(), []);
|
||||
const menuScene = useMemo(() => new MenuScene(), []);
|
||||
|
||||
@@ -21,7 +16,7 @@ export default function App() {
|
||||
<div className="flex-1 flex relative justify-center items-center">
|
||||
<PhaserGame initialScene="MenuScene">
|
||||
<PhaserScene sceneKey="MenuScene" scene={menuScene} />
|
||||
<PhaserScene sceneKey="GameScene" scene={gameScene} data={gameHost}/>
|
||||
<PhaserScene sceneKey="GameScene" scene={gameScene} data={{gameHost}}/>
|
||||
</PhaserGame>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user