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.
This commit is contained in:
parent
5355afb23e
commit
887da22baa
|
|
@ -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<TData = {}>(props: PhaserSceneProps<TData>) {
|
|||
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 = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue