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

UI 图片控件,在屏幕空间绘制一张精灵 更多...

#include <UIImage.h>

类 UIImage 继承关系图:
UIRendererComponent Component

Public 成员函数

 UIImage ()=default
 UIImage (const std::string &texturePath)
 ~UIImage () override
void onRender (const SDL_FRect &screenRect) override
 子类实现:在给定屏幕矩形内绘制自身(通过 Renderer 静态 API 绘制)
void onDestroy () 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
const Color & getColor () const
void setColor (const Color &color)
Public 成员函数 继承自 UIRendererComponent
 UIRendererComponent ()
 ~UIRendererComponent () override=default
void onAttach () override
void onDetach () override
void onDestroy () override
virtual bool containsPoint (const SDL_FRect &screenRect, const Vector2 &point) const
 点击命中检测:默认矩形内即命中,子类可覆写为更精确的形状
int getZIndex () const
void setZIndex (int zIndex)
bool isVisible () const
void setVisible (bool visible)
Public 成员函数 继承自 Component
 Component ()
virtual ~Component ()=default
virtual void onCreate ()
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(仅引擎反序列化/索引维护使用;正常流程由构造函数随机分配)

额外继承的成员函数

Protected 成员函数 继承自 UIRendererComponent
void requestSort ()
 components变更后通知系统重排(实例:zIndex 变化)
Protected 成员函数 继承自 Component
void setRegistered (bool registered)
静态 Protected 成员函数 继承自 UIRendererComponent
static SDL_Color toSDLColor (const Color &color)
 Color → SDL_Color 边界转换(供 UIText / UITextInput 系列传给 SDL_ttf 用)
Protected 属性 继承自 UIRendererComponent
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 仅在序列化前尚未赋值时短暂存在)

详细描述

UI 图片控件,在屏幕空间绘制一张精灵

继承 UIRendererComponent,由 UIRenderSystem 每帧调用 onRender。 位置 / 尺寸由同 GameObject 上的 UITransform 决定;Color 用于按钮状态着色。 不走游戏世界的相机变换,直接用屏幕坐标。

构造及析构函数说明

◆ UIImage() [1/2]

UIImage ( )
default

◆ UIImage() [2/2]

UIImage ( const std::string & texturePath)
explicit

◆ ~UIImage()

~UIImage ( )
override

成员函数说明

◆ getColor()

const Color & getColor ( ) const
inline

◆ getSourceRect()

const std::optional< Rect > & getSourceRect ( ) const
inline

◆ getTexturePath()

const std::string & getTexturePath ( ) const
inline

◆ isFlipped()

bool isFlipped ( ) const
inline

◆ onDestroy()

void onDestroy ( )
overridevirtual

重载 Component .

◆ onRender()

void onRender ( const SDL_FRect & screenRect)
overridevirtual

子类实现:在给定屏幕矩形内绘制自身(通过 Renderer 静态 API 绘制)

实现了 UIRendererComponent.

◆ setColor()

void setColor ( const Color & color)
inline

◆ setFlipped()

void setFlipped ( bool flipped)
inline

◆ setSourceRect()

void setSourceRect ( const std::optional< Rect > & sourceRect)
inline

◆ setTexturePath()

void setTexturePath ( const std::string & texturePath)
inline

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