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; }