60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
|
|
#pragma once
|
|||
|
|
|
|||
|
|
#include <kiwano/kiwano.h>
|
|||
|
|
using namespace kiwano;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace kiwano
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
KGE_DECLARE_SMART_PTR(SpriteEx);
|
|||
|
|
class SpriteEx :public Sprite
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
void OnUpdate(Duration dt) override;
|
|||
|
|
void OnRender(RenderContext& ctx) override;
|
|||
|
|
void Update(Duration dt)override;
|
|||
|
|
void Render(RenderContext& ctx)override;
|
|||
|
|
void RenderBorder(RenderContext& ctx)override;
|
|||
|
|
private:
|
|||
|
|
int MyModel = -1;
|
|||
|
|
public:
|
|||
|
|
void SetMode(const int Type);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
inline void SpriteEx::SetMode(const int Type) {
|
|||
|
|
MyModel = Type;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline void SpriteEx::OnUpdate(Duration dt) {
|
|||
|
|
Sprite::OnUpdate(dt);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline void SpriteEx::OnRender(RenderContext& ctx) {
|
|||
|
|
switch (MyModel)
|
|||
|
|
{
|
|||
|
|
case -1: //-1ԭʼģʽ
|
|||
|
|
ctx.SetBlendMode(BlendMode::SourceOver);
|
|||
|
|
break;
|
|||
|
|
case 0: //0<><30><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
ctx.SetBlendMode(BlendMode::Add);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
ctx.SetBlendMode(BlendMode::SourceOver);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
Sprite::OnRender(ctx);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline void SpriteEx::Update(Duration dt) {
|
|||
|
|
Sprite::Update(dt);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline void SpriteEx::Render(RenderContext& ctx) {
|
|||
|
|
Sprite::Render(ctx);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
inline void SpriteEx::RenderBorder(RenderContext& ctx) {
|
|||
|
|
Sprite::RenderBorder(ctx);
|
|||
|
|
}
|
|||
|
|
}
|