|
ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
|
场景类 更多...
#include <Scene.h>
Public 成员函数 | |
| Scene (const std::string &name) | |
| ~Scene () | |
| Scene (const Scene &)=delete | |
| Scene & | operator= (const Scene &)=delete |
| Scene (Scene &&)=delete | |
| Scene & | operator= (Scene &&)=delete |
| virtual void | init () |
| 注册默认系统(BehaviorSystem + RenderSystem) | |
| void | update () |
| 更新所有 System + 处理延迟操作 | |
| virtual void | destroy () |
| 销毁所有对象与系统 | |
| void | addGameObject (std::unique_ptr< GameObject > &&gameObject) |
| 延迟添加 GameObject(帧末生效) | |
| GameObject * | createGameObject (const std::string &name) |
| 创建并添加 GameObject | |
| GameObject * | instantiate (const Prefab &prefab, const std::string &name="") |
| 从预制体实例化 | |
| void | removeGameObject (GameObject *gameObject) |
| 按指针标记销毁 | |
| void | removeGameObjectByName (const std::string &name) |
| 按名称标记销毁 | |
| template<typename T> | |
| T * | registerSystem () |
| template<typename T> | |
| void | unregisterSystem () |
| template<typename T> | |
| T * | getSystem () |
| template<typename T> | |
| bool | hasSystem () |
| const std::string & | getName () const |
| std::vector< std::unique_ptr< GameObject > > & | getGameObjects () |
| void | setName (const std::string &name) |
场景类
场景是游戏世界的容器,管理所有 GameObject、System 的生命周期。 通过 SceneManager 的栈机制实现场景切换(主菜单→游戏→暂停)。
使用方式: auto scene = std::make_unique<Scene>("level1"); scene->init(); // 注册默认 BehaviorSystem + RenderSystem auto* player = scene->createGameObject("player"); SceneManager::PushScene(std::move(scene));
|
explicit |
| ~Scene | ( | ) |
|
delete |
|
delete |
| void addGameObject | ( | std::unique_ptr< GameObject > && | gameObject | ) |
延迟添加 GameObject(帧末生效)
| GameObject * createGameObject | ( | const std::string & | name | ) |
创建并添加 GameObject
|
virtual |
销毁所有对象与系统
|
inline |
|
inline |
|
inline |
|
inline |
|
virtual |
注册默认系统(BehaviorSystem + RenderSystem)
| GameObject * instantiate | ( | const Prefab & | prefab, |
| const std::string & | name = "" ) |
从预制体实例化
|
inline |
| void removeGameObject | ( | GameObject * | gameObject | ) |
按指针标记销毁
| void removeGameObjectByName | ( | const std::string & | name | ) |
按名称标记销毁
|
inline |
|
inline |
| void update | ( | ) |
更新所有 System + 处理延迟操作