From 887da22baa3044f8614e1dc20ab3ffba719e94f4 Mon Sep 17 00:00:00 2001 From: hypercross Date: Wed, 22 Apr 2026 00:55:38 +0800 Subject: [PATCH] fix(framework): check instance of Scene in PhaserScene Ensure the scene passed to PhaserScene is an instance of Phaser.Scene before deciding whether to instantiate it. --- packages/framework/src/ui/PhaserBridge.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/ui/PhaserBridge.tsx b/packages/framework/src/ui/PhaserBridge.tsx index 9737441..67e5d33 100644 --- a/packages/framework/src/ui/PhaserBridge.tsx +++ b/packages/framework/src/ui/PhaserBridge.tsx @@ -1,5 +1,5 @@ import { signal, useSignal, useSignalEffect } from "@preact/signals"; -import Phaser, { AUTO } from "phaser"; +import Phaser, { AUTO, Scene } from "phaser"; import { createContext } from "preact"; import { useContext, useEffect, useRef } from "preact/hooks"; @@ -215,7 +215,8 @@ export function PhaserScene(props: PhaserSceneProps) { const game = ctx.game; // 注册场景到 Phaser(但不启动) - const scene = "scene" in props.scene ? props.scene : new props.scene(); + const scene = + props.scene instanceof Scene ? props.scene : new props.scene(); const sceneKey = props.sceneKey ?? scene.sys.settings.key; if (!game.scene.getScene(sceneKey)) { const initData = {