ShitEngine
基于 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< SDL_FRect > &sourceRect)
const std::optional< SDL_FRect > & getSourceRect () const
void setFlipped (bool flipped)
bool isFlipped () const
const ColorgetColor () 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、无法自动触发的引擎状态"(如精灵纹理加载)。
 Component (const Component &)=delete
Componentoperator= (const Component &)=delete
 Component (Component &&)=delete
Componentoperator= (Component &&)=delete
GameObjectgetOwner () const
bool isRegistered () const

额外继承的成员函数

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
GameObjectm_owner = nullptr
bool m_isRegistered = false

详细描述

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< SDL_FRect > & 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< SDL_FRect > & sourceRect)
inline

◆ setTexturePath()

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

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