![]() |
ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
|
精灵组件 更多...
#include <SpriteRenderer.h>
Public 成员函数 | |
| SpriteRenderer ()=default | |
| ~SpriteRenderer () override=default | |
| void | onRender (SDL_Renderer *renderer, const CameraComponent *camera) const override |
| 纯虚:子类实现绘制逻辑 | |
| void | setTexturePath (const std::string &texturePath) |
| const std::string & | getTexturePath () const |
| void | setSourceRect (const std::optional< Rect > &sourceRect) |
| const std::optional< Rect > & | getSourceRect () const |
| void | setFlipped (bool flipped) |
| bool | isFlipped () const |
| 是否水平翻转 | |
| float | getSourceRectX () const |
| Source Rect X | |
| void | setSourceRectX (float v) |
| float | getSourceRectY () const |
| Source Rect Y | |
| void | setSourceRectY (float v) |
| float | getSourceRectW () const |
| Source Rect Width | |
| void | setSourceRectW (float v) |
| float | getSourceRectH () const |
| Source Rect Height | |
| void | setSourceRectH (float v) |
| void | onAfterDeserialize () override |
| 反序列化完成后回调(Prefab::apply 逐组件调用一次,字段已写入)。 用于重建"直写字段绕过了 setter、无法自动触发的引擎状态"(如精灵纹理加载)。 | |
| SDL_FRect | getGlobalBounds () override |
| 世界坐标下的轴对齐包围盒 | |
| Public 成员函数 继承自 RendererComponent | |
| RendererComponent () | |
| ~RendererComponent () override=default | |
| void | onAttach () override |
| void | onDetach () override |
| void | onDestroy () override |
| int | getZIndex () const |
| 渲染层级,值越大越靠上 | |
| bool | isVisible () const |
| 是否可见 | |
| void | setZIndex (int zIndex) |
| void | setVisible (bool isVisible) |
| Public 成员函数 继承自 Component | |
| Component () | |
| virtual | ~Component ()=default |
| virtual void | onCreate () |
| virtual void | onFieldChanged (const std::string &fieldName) |
| 检查器直接写反射字段后回调(字段名)。用于绕过 setter 的直写完成后 重新同步引擎状态(如 Box2D 刚体/形状)。默认无操作。 | |
| Component (const Component &)=delete | |
| Component & | operator= (const Component &)=delete |
| Component (Component &&)=delete | |
| Component & | operator= (Component &&)=delete |
| GameObject * | getOwner () const |
| bool | isRegistered () const |
| uint64_t | getUuid () const |
| 组件持久 ID(随 .scene 序列化,是 ComponentRef<T> 引用字段的寻址依据) | |
| void | setUuid (uint64_t uuid) |
| 直接设置组件 ID(仅引擎反序列化/索引维护使用;正常流程由构造函数随机分配) | |
友元 | |
| class | GameObject |
额外继承的成员函数 | |
| Protected 成员函数 继承自 Component | |
| void | setRegistered (bool registered) |
| Protected 属性 继承自 RendererComponent | |
| int | m_zIndex = 0 |
| bool | m_isVisible = true |
| Protected 属性 继承自 Component | |
| GameObject * | m_owner = nullptr |
| bool | m_isRegistered = false |
| uint64_t | m_uuid = 0 |
| 持久 ID(构造时随机分配;0 仅在序列化前尚未赋值时短暂存在) | |
精灵组件
内部持有 Sprite 对象描述"画什么"。 整图渲染时 sourceRect 留空;用于 sprite-sheet 逐帧动画时, 由 AnimationComponent 把当前帧的 Rect 写回 setSourceRect。
|
default |
|
overridedefault |
|
overridevirtual |
世界坐标下的轴对齐包围盒
实现了 RendererComponent.
|
inline |
| float getSourceRectH | ( | ) | const |
Source Rect Height
| float getSourceRectW | ( | ) | const |
Source Rect Width
| float getSourceRectX | ( | ) | const |
Source Rect X
| float getSourceRectY | ( | ) | const |
Source Rect Y
|
inline |
|
inline |
是否水平翻转
|
overridevirtual |
反序列化完成后回调(Prefab::apply 逐组件调用一次,字段已写入)。 用于重建"直写字段绕过了 setter、无法自动触发的引擎状态"(如精灵纹理加载)。
重载 Component .
|
overridevirtual |
纯虚:子类实现绘制逻辑
实现了 RendererComponent.
|
inline |
|
inline |
| void setSourceRectH | ( | float | v | ) |
| void setSourceRectW | ( | float | v | ) |
| void setSourceRectX | ( | float | v | ) |
| void setSourceRectY | ( | float | v | ) |
| void setTexturePath | ( | const std::string & | texturePath | ) |
|
friend |