[deploy] Update Sprite
This commit is contained in:
parent
d31c66a60e
commit
6a25403841
|
|
@ -96,6 +96,18 @@ public:
|
||||||
/// @brief 获取裁剪矩形
|
/// @brief 获取裁剪矩形
|
||||||
Rect const& GetCropRect() const;
|
Rect const& GetCropRect() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取图像原宽度
|
||||||
|
float GetSourceWidth() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取图像原高度
|
||||||
|
float GetSourceHeight() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取图像原大小
|
||||||
|
Size GetSourceSize() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取纹理
|
/// @brief 获取纹理
|
||||||
TexturePtr GetTexture() const;
|
TexturePtr GetTexture() const;
|
||||||
|
|
@ -135,6 +147,33 @@ inline Rect const& Frame::GetCropRect() const
|
||||||
return crop_rect_;
|
return crop_rect_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline float Frame::GetSourceWidth() const
|
||||||
|
{
|
||||||
|
if (texture_)
|
||||||
|
{
|
||||||
|
return texture_->GetWidth();
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float Frame::GetSourceHeight() const
|
||||||
|
{
|
||||||
|
if (texture_)
|
||||||
|
{
|
||||||
|
return texture_->GetHeight();
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Size Frame::GetSourceSize() const
|
||||||
|
{
|
||||||
|
if (texture_)
|
||||||
|
{
|
||||||
|
return texture_->GetSize();
|
||||||
|
}
|
||||||
|
return Size();
|
||||||
|
}
|
||||||
|
|
||||||
inline TexturePtr Frame::GetTexture() const
|
inline TexturePtr Frame::GetTexture() const
|
||||||
{
|
{
|
||||||
return texture_;
|
return texture_;
|
||||||
|
|
|
||||||
|
|
@ -102,12 +102,47 @@ bool Sprite::Load(Resource const& res, bool autoresize)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Sprite::GetSourceWidth() const
|
||||||
|
{
|
||||||
|
if (frame_)
|
||||||
|
{
|
||||||
|
return frame_->GetSourceWidth();
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Sprite::GetSourceHeight() const
|
||||||
|
{
|
||||||
|
if (frame_)
|
||||||
|
{
|
||||||
|
return frame_->GetSourceHeight();
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
Size Sprite::GetSourceSize() const
|
||||||
|
{
|
||||||
|
if (frame_)
|
||||||
|
{
|
||||||
|
return frame_->GetSourceSize();
|
||||||
|
}
|
||||||
|
return Size();
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect Sprite::GetCropRect() const
|
||||||
|
{
|
||||||
|
if (frame_)
|
||||||
|
{
|
||||||
|
return frame_->GetCropRect();
|
||||||
|
}
|
||||||
|
return Rect();
|
||||||
|
}
|
||||||
|
|
||||||
void Sprite::SetCropRect(const Rect& crop_rect)
|
void Sprite::SetCropRect(const Rect& crop_rect)
|
||||||
{
|
{
|
||||||
if (frame_)
|
if (frame_)
|
||||||
{
|
{
|
||||||
frame_->SetCropRect(crop_rect);
|
frame_->SetCropRect(crop_rect);
|
||||||
SetSize(Size{ frame_->GetWidth(), frame_->GetHeight() });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +153,7 @@ void Sprite::SetFrame(FramePtr frame, bool autoresize)
|
||||||
frame_ = frame;
|
frame_ = frame;
|
||||||
if (frame_ && autoresize)
|
if (frame_ && autoresize)
|
||||||
{
|
{
|
||||||
SetSize(Size{ frame_->GetWidth(), frame_->GetHeight() });
|
SetSize(frame_->GetSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,15 +72,31 @@ public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 加载本地图片
|
/// @brief 加载本地图片
|
||||||
/// @param file_path 本地图片路径
|
/// @param file_path 本地图片路径
|
||||||
/// @param[in] autoresize 是否自动调整自身大小为图像大小
|
/// @param autoresize 是否自动调整自身大小为图像大小
|
||||||
bool Load(String const& file_path, bool autoresize = true);
|
bool Load(String const& file_path, bool autoresize = true);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 加载图像资源
|
/// @brief 加载图像资源
|
||||||
/// @param res 图片资源
|
/// @param res 图片资源
|
||||||
/// @param[in] autoresize 是否自动调整自身大小为图像大小
|
/// @param autoresize 是否自动调整自身大小为图像大小
|
||||||
bool Load(Resource const& res, bool autoresize = true);
|
bool Load(Resource const& res, bool autoresize = true);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取图像原宽度
|
||||||
|
float GetSourceWidth() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取图像原高度
|
||||||
|
float GetSourceHeight() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取图像原大小
|
||||||
|
Size GetSourceSize() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取裁剪矩形
|
||||||
|
Rect GetCropRect() const;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 使用矩形区域裁剪精灵
|
/// @brief 使用矩形区域裁剪精灵
|
||||||
/// @param crop_rect 裁剪矩形
|
/// @param crop_rect 裁剪矩形
|
||||||
|
|
@ -93,7 +109,7 @@ public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 设置图像帧
|
/// @brief 设置图像帧
|
||||||
/// @param[in] frame 图像帧
|
/// @param[in] frame 图像帧
|
||||||
/// @param[in] autoresize 是否自动调整自身大小为图像大小
|
/// @param autoresize 是否自动调整自身大小为图像大小
|
||||||
void SetFrame(FramePtr frame, bool autoresize = true);
|
void SetFrame(FramePtr frame, bool autoresize = true);
|
||||||
|
|
||||||
void OnRender(RenderContext& ctx) override;
|
void OnRender(RenderContext& ctx) override;
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,11 @@ struct ActionHelper
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ActionPtr operator->() const
|
||||||
|
{
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionPtr ptr;
|
ActionPtr ptr;
|
||||||
};
|
};
|
||||||
|
|
@ -199,6 +204,11 @@ struct TweenHelper
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ActionTweenPtr operator->() const
|
||||||
|
{
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionTweenPtr ptr;
|
ActionTweenPtr ptr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue