修改游戏底层矩阵相关
This commit is contained in:
44
source/EngineFrame/Component/NumberText.h
Normal file
44
source/EngineFrame/Component/NumberText.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Component/Text.h"
|
||||
#include "EngineCore/Game.h"
|
||||
#include "EngineFrame/Render/RenderManager.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
// 数字文本类,高效处理数字更新
|
||||
class NumberText : public Text
|
||||
{
|
||||
private:
|
||||
// 字体
|
||||
TTF_Font *m_font;
|
||||
// 文本颜色
|
||||
SDL_Color m_color;
|
||||
|
||||
// 当前数字
|
||||
int m_currentNumber = 0;
|
||||
// 数字字符纹理缓存('0'-'9'和'-')
|
||||
std::unordered_map<char, RefPtr<Texture>> m_digitTextures;
|
||||
// 当前数字的字符精灵列表
|
||||
std::vector<Sprite *> m_digitSprites;
|
||||
|
||||
// 预加载0-9和负号的纹理
|
||||
void PreloadDigits();
|
||||
|
||||
// 更新数字精灵(根据新数字字符串重新排列字符)
|
||||
void UpdateDigitSprites(const std::string &numStr);
|
||||
|
||||
public:
|
||||
// 构造函数:指定字体、颜色和字符尺寸
|
||||
NumberText(TTF_Font *font, SDL_Color color);
|
||||
|
||||
~NumberText();
|
||||
|
||||
// 设置数字(核心方法:仅更新变化的数字部分)
|
||||
void SetNumber(int number);
|
||||
|
||||
int GetNumber() const { return m_currentNumber; }
|
||||
|
||||
// 重写Render,绘制所有数字字符
|
||||
void Render() override;
|
||||
};
|
||||
Reference in New Issue
Block a user