From e011cea090bc3d7e773dad3e28583a01143c7c61 Mon Sep 17 00:00:00 2001 From: ChestnutYueyue <952134128@qq.com> Date: Tue, 3 Mar 2026 19:41:20 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E8=B0=83=E6=95=B4main.cpp=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=92=8Cinclude=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统一缩进为2个空格 - 调整头文件include顺序 - 移除多余的注释分隔线 --- examples/scene_graph_demo/main.cpp | 88 ++++++++++++++---------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/examples/scene_graph_demo/main.cpp b/examples/scene_graph_demo/main.cpp index 4d6cea4..bea30ed 100644 --- a/examples/scene_graph_demo/main.cpp +++ b/examples/scene_graph_demo/main.cpp @@ -12,9 +12,9 @@ * - SpriteRenderer 精灵渲染 */ -#include #include "game_scene.h" #include +#include using namespace extra2d; @@ -22,58 +22,54 @@ using namespace extra2d; * @brief 程序入口 */ int main(int argc, char **argv) { - // ======================================== - // 1. 创建应用 - // ======================================== - auto app = Application::create(); + // ======================================== + // 1. 创建应用 + // ======================================== + auto app = Application::create(); - AppConfig config; - config.title = "Scene Graph Demo - Extra2D"; - config.width = 1280; - config.height = 720; + AppConfig config; + config.title = "Scene Graph Demo - Extra2D"; + config.width = 1280; + config.height = 720; - if (!app->init(config)) { - printf("Failed to initialize application!\n"); - return -1; - } + if (!app->init(config)) { + printf("Failed to initialize application!\n"); + return -1; + } + // ======================================== + // 2. 获取场景模块和导演 + // ======================================== + SceneModule *sceneModule = app->getModule(); + if (!sceneModule) { + printf("Failed to get SceneModule!\n"); + return -1; + } - printf("Application initialized successfully\n"); - printf("Window size: %dx%d\n", app->getWindowWidth(), app->getWindowHeight()); + Director *director = sceneModule->getDirector(); + if (!director) { + printf("Failed to get Director!\n"); + return -1; + } - // ======================================== - // 2. 获取场景模块和导演 - // ======================================== - SceneModule *sceneModule = app->getModule(); - if (!sceneModule) { - printf("Failed to get SceneModule!\n"); - return -1; - } + printf("Scene module and director ready\n"); - Director *director = sceneModule->getDirector(); - if (!director) { - printf("Failed to get Director!\n"); - return -1; - } + // ======================================== + // 3. 创建并运行游戏场景 + // ======================================== + auto gameScene = makePtr(); + director->runScene(gameScene); - printf("Scene module and director ready\n"); + printf("Game scene started\n"); - // ======================================== - // 3. 创建并运行游戏场景 - // ======================================== - auto gameScene = makePtr(); - director->runScene(gameScene); + // ======================================== + // 4. 运行应用主循环 + // ======================================== + app->run(); - printf("Game scene started\n"); + // ======================================== + // 5. 清理(自动进行) + // ======================================== + printf("Application shutting down...\n"); - // ======================================== - // 4. 运行应用主循环 - // ======================================== - app->run(); - - // ======================================== - // 5. 清理(自动进行) - // ======================================== - printf("Application shutting down...\n"); - - return 0; + return 0; }