#pragma once #include #include "Asset/Asset_ImagePack.h" #include "EngineFrame/Component/RenderBase.h" #include "EngineFrame/Render/Texture.h" class Game; /** * @brief Sprite类,继承自Component类,用于表示游戏中的精灵组件 */ class Sprite : public RenderBase { protected: RefPtr m_texture = nullptr; public: Sprite() = default; Sprite(std::string imgPath, int Index); Sprite(std::string PngPath); ~Sprite(); void Render() override; void PreRender() override; void Clear() override; void Init() override; RefPtr GetTexture(); public: // 渲染信息 RenderGuidanceInfo _RenderGuidanceInfo; // 裁切数据 SDL_Rect CropRect = {0, 0, 0, 0}; // 裁切Flag bool CropFlag = false; // 阴影数据 std::array vertices; // 阴影Flag bool ShadowFlag = false; std::string imgPath; int Index; public: // 计算渲染信息 void CalcRenderInfoLogic(); // 设置裁切区域 void SetClipRect(SDL_Rect clipRect); // 取消裁切区域 void UnsetClipRect(); // 设置混合模式 void SetBlendMode(SDL_BlendMode blendMode); // 获取混合模式 SDL_BlendMode GetBlendMode(); // 设置阴影 void SetShadow(); // 计算阴影数据 void CalculateShadowData(); };