- Add Component class documentation with lifecycle methods - Add GameObject class documentation with component system - Add TransformComponent documentation with transform methods - Add Scene class documentation with GameObject management - Add SceneManager singleton documentation with scene loading - Update components.md overview with all component classes - Update main.md navigation with Scene module
47 lines
1.4 KiB
Markdown
47 lines
1.4 KiB
Markdown
# Scene 模块概览
|
||
|
||
**命名空间**: `XCEngine::Components`
|
||
|
||
**类型**: `module`
|
||
|
||
**描述**: XCEngine 的场景管理模块,提供场景创建、加载和 GameObject 管理功能。
|
||
|
||
## 概述
|
||
|
||
Scene 模块是 XCEngine 中管理游戏场景的核心模块。它提供了 Scene 类用于管理场景中的所有 GameObject,以及 SceneManager 单例用于管理多个场景、场景切换和生命周期。场景是 GameObject 的容器,支持场景保存/加载、子对象查找、事件通知等功能。
|
||
|
||
## 模块内容
|
||
|
||
### 核心类
|
||
|
||
| 组件 | 文件 | 描述 |
|
||
|------|------|------|
|
||
| [Scene](scene/scene.md) | `Scene.h` | 场景类,管理 GameObject 层级和生命周期 |
|
||
| [SceneManager](scene-manager/scene-manager.md) | `SceneManager.h` | 场景管理器单例,管理所有场景 |
|
||
|
||
## 使用示例
|
||
|
||
```cpp
|
||
#include <XCEngine/Scene/SceneManager.h>
|
||
#include <XCEngine/Scene/Scene.h>
|
||
#include <XCEngine/Components/GameObject.h>
|
||
|
||
using namespace XCEngine::Components;
|
||
|
||
void CreateNewScene() {
|
||
Scene* scene = SceneManager::Get().CreateScene("MainMenu");
|
||
SceneManager::Get().SetActiveScene(scene);
|
||
|
||
GameObject* camera = scene->CreateGameObject("MainCamera");
|
||
}
|
||
|
||
void LoadSceneExample() {
|
||
SceneManager::Get().LoadScene("levels/gameplay.json");
|
||
}
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [Components 模块](../components/components.md) - Components 模块总览
|
||
- [GameObject](../components/game-object/game-object.md) - 游戏对象
|