Files
DNF_DEV/source/EngineFrame/Component/Sprite.h

58 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <string>
#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<Texture> 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<Texture> GetTexture();
public:
// 渲染信息
RenderGuidanceInfo _RenderGuidanceInfo;
// 裁切数据
SDL_Rect CropRect = {0, 0, 0, 0};
// 裁切Flag
bool CropFlag = false;
// 阴影数据
std::array<SDL_Vertex, 4> 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();
};