45 lines
1016 B
C++
45 lines
1016 B
C++
#include "Chr_Shadow.h"
|
|
#include "Global/Global_Game.h"
|
|
#include "Actor/Object/CharacterObject.h"
|
|
#include "Asset/Character/Chr_Equipment.h"
|
|
|
|
void Chr_Shadow::Init(CharacterObject *parent)
|
|
{
|
|
// 调用RenderBase类的初始化 才能挂上标签
|
|
RenderBase::Init();
|
|
chr_parent = parent;
|
|
SetRenderZOrder(1000000);
|
|
SetPos(parent->GetPos());
|
|
}
|
|
|
|
void Chr_Shadow::SetAction(std::string actionName)
|
|
{
|
|
// 先将原动作的Ani设置为不可见
|
|
for (auto Ani : ActionAnis[CurrentActionTag])
|
|
{
|
|
Ani->Reset();
|
|
Ani->SetVisible(false);
|
|
}
|
|
// 再将新动作的Ani设置为可见
|
|
for (auto Ani : ActionAnis[actionName])
|
|
{
|
|
Ani->SetVisible(true);
|
|
}
|
|
CurrentActionTag = actionName;
|
|
}
|
|
|
|
void Chr_Shadow::SetDirection(int dir)
|
|
{
|
|
VecFPos sc = GetScale();
|
|
// 朝右
|
|
if (dir == 0)
|
|
{
|
|
SetScale(VecFPos({SDL_fabsf(sc.x), sc.y}));
|
|
}
|
|
// 朝左
|
|
else if (dir == 1)
|
|
{
|
|
SetScale(VecFPos({-SDL_fabsf(sc.x), sc.y}));
|
|
}
|
|
}
|