#include "hello_module.h" #include using namespace extra2d; /** * @brief 自定义场景类 * * 展示如何在场景中使用自定义模块 */ class HelloScene : public Scene { public: static Ptr create() { return makeShared(); } void onEnter() override { Scene::onEnter(); addListener(EventType::KeyPressed, [](Event &e) { auto &keyEvent = std::get(e.data); if (keyEvent.keyCode == static_cast(Key::Escape)) { e.handled = true; E2D_LOG_INFO("ESC !!!exit"); Application::get().quit(); } }); E2D_LOG_INFO("HelloScene entered"); setBackgroundColor(Color(0.1f, 0.1f, 0.2f, 1.0f)); } private: }; /** * @brief 应用程序入口 */ int main(int argc, char *argv[]) { Application &app = Application::get(); HelloModule helloModule; app.use(helloModule); AppConfig appConfig; appConfig.appName = "HelloModule Example"; appConfig.appVersion = "1.0.0"; if (!app.init(appConfig)) { E2D_LOG_ERROR("Failed to initialize application"); return 1; } auto scene = HelloScene::create(); app.enterScene(scene); app.run(); app.shutdown(); return 0; }