31 lines
588 B
C++
31 lines
588 B
C++
#pragma once
|
||
|
||
#include <SDL2/SDL_ttf.h>
|
||
#include "EngineFrame/Component/Sprite.h"
|
||
|
||
class Text : public Sprite
|
||
{
|
||
public:
|
||
Text(/* args */);
|
||
~Text();
|
||
|
||
// 显式引入基类的Init方法,避免隐藏
|
||
using Component::Init;
|
||
void Init(std::string Str, TTF_Font *font, SDL_Color color);
|
||
void Render() override;
|
||
|
||
public:
|
||
/** 文本内容 */
|
||
std::string m_text;
|
||
/** 字体 */
|
||
TTF_Font *m_font;
|
||
/** 字体颜色 */
|
||
SDL_Color m_color;
|
||
|
||
public:
|
||
// 设置文本
|
||
void SetText(std::string Str);
|
||
// 获取文本
|
||
std::string GetText();
|
||
};
|