ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
TransformComponent类 参考

变换组件,决定 GameObject 的位置 / 缩放 / 旋转 更多...

#include <TransformComponent.h>

类 TransformComponent 继承关系图:
Component

Public 成员函数

 TransformComponent ()
 ~TransformComponent () override=default
const Vector2 & getPosition () const
void setPosition (const Vector2 &position)
const Vector2 & getScale () const
void setScale (const Vector2 &scale)
float getRotation () const
void setRotation (float rotation)
Public 成员函数 继承自 Component
 Component ()
virtual ~Component ()=default
virtual void onCreate ()
virtual void onAttach ()
virtual void onDetach ()
virtual void onDestroy ()
virtual void onAfterDeserialize ()
 反序列化完成后回调(Prefab::apply 逐组件调用一次,字段已写入)。 用于重建"直写字段绕过了 setter、无法自动触发的引擎状态"(如精灵纹理加载)。
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 属性 继承自 Component
GameObject * m_owner = nullptr
bool m_isRegistered = false
uint64_t m_uuid = 0
 持久 ID(构造时随机分配;0 仅在序列化前尚未赋值时短暂存在)

详细描述

变换组件,决定 GameObject 的位置 / 缩放 / 旋转

构造及析构函数说明

◆ TransformComponent()

TransformComponent ( )
explicit

◆ ~TransformComponent()

~TransformComponent ( )
overridedefault

成员函数说明

◆ getPosition()

const Vector2 & getPosition ( ) const
inline

◆ getRotation()

float getRotation ( ) const
inline

◆ getScale()

const Vector2 & getScale ( ) const
inline

◆ setPosition()

void setPosition ( const Vector2 & position)
inline

◆ setRotation()

void setRotation ( float rotation)
inline

◆ setScale()

void setScale ( const Vector2 & scale)
inline

◆ GameObject

friend class GameObject
friend

该类的文档由以下文件生成: