Files
XCEngine/docs/api/components/components.md
ssdfasd a9d5a68dd6 docs: Add Component, GameObject, TransformComponent and Scene API documentation
- 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
2026-03-22 03:33:55 +08:00

59 lines
1.8 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.
# Components 模块概览
**命名空间**: `XCEngine::Components`
**类型**: `module`
**描述**: XCEngine 的 ECS实体组件系统组件模块。
## 概述
Components 模块是 XCEngine ECS 架构中的组件层提供各种游戏对象组件。这些组件附加到实体Entity定义了游戏对象的行为和数据。组件系统支持 Transform、Audio、Render 等功能。
## 模块内容
### 核心组件
| 组件 | 文件 | 描述 |
|------|------|------|
| [Component](component/component.md) | `Component.h` | 组件基类,所有组件的父类 |
| [GameObject](game-object/game-object.md) | `GameObject.h` | 游戏对象实体 |
### 变换组件
| 组件 | 文件 | 描述 |
|------|------|------|
| [TransformComponent](transform-component/transform-component.md) | `TransformComponent.h` | 变换组件,包含位置、旋转、缩放 |
### 音频组件
| 组件 | 文件 | 描述 |
|------|------|------|
| [AudioSourceComponent](audio-source/audio-source-component.md) | `AudioSourceComponent.h` | 音频源组件,负责播放音频 |
| [AudioListenerComponent](audio-listener/audio-listener-component.md) | `AudioListenerComponent.h` | 音频监听器组件,接收声音 |
## 使用示例
```cpp
#include <XCEngine/Components/GameObject.h>
#include <XCEngine/Components/TransformComponent.h>
#include <XCEngine/Components/AudioSourceComponent.h>
using namespace XCEngine::Components;
void CreateAudioEntity() {
GameObject* entity = new GameObject("AudioEntity");
auto transform = entity->AddComponent<TransformComponent>();
transform->SetPosition(Vector3(0, 0, 0));
auto audioSource = entity->AddComponent<AudioSourceComponent>();
audioSource->SetVolume(0.8f);
}
```
## 相关文档
- [Audio 模块](../audio/audio.md) - 音频系统模块
- [Core 模块](../core/core.md) - ECS 核心类型