diff --git a/examples/collision_demo/main.cpp b/examples/collision_demo/main.cpp index 3d382a4..2c1b0b4 100644 --- a/examples/collision_demo/main.cpp +++ b/examples/collision_demo/main.cpp @@ -68,7 +68,7 @@ public: // 创建移动的中心方块 centerBox_ = - makePtr(80.0f, 80.0f, Color(0.2f, 0.6f, 1.0f, 0.8f)); + shared(80.0f, 80.0f, Color(0.2f, 0.6f, 1.0f, 0.8f)); centerBox_->setPosition(Vec2(centerX, centerY)); addChild(centerBox_); @@ -184,7 +184,7 @@ private: }; for (const auto &[pos, color] : positions) { - auto box = makePtr(70.0f, 70.0f, color); + auto box = shared(70.0f, 70.0f, color); box->setPosition(pos); addChild(box); boxes_.push_back(box); @@ -267,7 +267,7 @@ int main(int argc, char **argv) { } // 进入场景 - app.enterScene(makePtr()); + app.enterScene(shared()); E2D_LOG_INFO("开始主循环..."); diff --git a/examples/hello_world/main.cpp b/examples/hello_world/main.cpp index 1d72b17..c8fd8a7 100644 --- a/examples/hello_world/main.cpp +++ b/examples/hello_world/main.cpp @@ -111,7 +111,7 @@ int main(int argc, char **argv) { } // 进入 Hello World 场景 - app.enterScene(makePtr()); + app.enterScene(shared()); E2D_LOG_INFO("开始主循环..."); diff --git a/include/core/types.h b/include/core/types.h index fb75de7..ee93b7d 100644 --- a/include/core/types.h +++ b/include/core/types.h @@ -17,13 +17,13 @@ template using UniquePtr = std::unique_ptr; template using WeakPtr = std::weak_ptr; /// 创建 shared_ptr 的便捷函数 -template inline Ptr makePtr(Args &&...args) { +template inline Ptr shared(Args &&...args) { return std::make_shared(std::forward(args)...); } /// 创建 unique_ptr 的便捷函数 template -inline UniquePtr makeUnique(Args &&...args) { +inline UniquePtr unique(Args &&...args) { return std::make_unique(std::forward(args)...); } diff --git a/src/app/application.cpp b/src/app/application.cpp index 5924d0f..1bad306 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -2,17 +2,18 @@ #include