Files
XCEngine/docs/api/scene/scene.md
ssdfasd 1f97102f33 docs: 更新 audio 和 scene 模块文档
- audio: 更新 i-audio-backend, i-audio-effect, wasapi-backend 方法文档
- scene: 更新 scene.md 模块总览
2026-03-26 01:53:04 +08:00

47 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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) - 游戏对象