From 72897d469b65404d220624dba0cbb35e5d5f9e12 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sun, 19 Apr 2026 13:34:26 +0800 Subject: [PATCH] refactor: update main.ts for new architecture --- src/main.ts | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/main.ts b/src/main.ts index 05e7370..4703535 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,32 +1,16 @@ -import { Assets } from "pixi.js"; -import { EDirection } from "./enmu"; -import { gameManager, initGame, stageManager } from "./Game"; -import Game from "./Game/Game"; -import { initAssets } from "./Game/Assets"; +import { Orientation } from "./enums/Orientation"; +import { initApp, game, sceneManager } from "./init"; -// gameManager.loader -// // .add("my-sound", "/bg.mp3", (e) => addSound(e)) // 背景音乐 -// .add("bg", "/bg.png") // 背景图片 -// .add("dnf", "https://www.kkkk1000.com/images/learnPixiJS-AnimatedSprite/dnf.png") // 背景图片 -// .add("btn-bg", "/assets/images/button_square_depth_gloss.png") // 背景图片 -// .add("btn-bg-press", "/assets/images/button_square_depth_gradient.png") // 背景图片 -// .load(); +// 初始化应用 +setTimeout(async () => { + await initApp(); + game.setOrientation(Orientation.Landscape); + // 入口场景会自动由 SceneManager 发现和初始化 + // 如果你的入口场景叫 "init",它会被自动初始化 +}, 200); -// gameManager.loader.onProgress.add((loader) => { -// console.log(loader.progress); -// }); -// gameManager.loader.onComplete.once((loader) => { -// console.log(loader.resources); -// initGame(); -// gameManager.setDirection(EDirection.Landscape); -// stageManager.initStage("init"); -// }); - -setTimeout(() => { - ;(async ()=>{ - await initAssets(); - await Game.getInstance().init() - initGame(); - gameManager.setDirection(EDirection.Landscape); - })() -}, 200); \ No newline at end of file +// 导出供全局调试 +if (import.meta.env.DEV) { + (window as any).game = game; + (window as any).sceneManager = sceneManager; +} \ No newline at end of file