40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#include "Mon_Animation.h"
|
|
#include "Actor/Object/MonsterObject.h"
|
|
#include "Global/Global_Game.h"
|
|
void Mon_Animation::Init(MonsterObject *parent)
|
|
{
|
|
// 调用RenderBase类的初始化 才能挂上标签
|
|
RenderBase::Init();
|
|
parent->AddChild(this);
|
|
mon_parent = parent;
|
|
|
|
GlobalMonsterScript::MonsterConfig Config = Global_Game::GetInstance().GetMonsterInfo(mon_parent->Id);
|
|
|
|
// 遍历所有动作Ani路径
|
|
for (const auto &pair : Config.animationPath)
|
|
{
|
|
std::string ActionName = pair.first;
|
|
std::string Path = std::string(Config.folder + Tool_toLowerCase(pair.second));
|
|
|
|
RefPtr<Animation> Ani = new Animation(Path);
|
|
this->ActionAnis[ActionName] = Ani;
|
|
Ani->SetVisible(false);
|
|
this->AddChild(Ani);
|
|
}
|
|
|
|
// 默认动作
|
|
this->SetAction("waiting");
|
|
}
|
|
|
|
void Mon_Animation::SetAction(std::string actionName)
|
|
{
|
|
// 先将原动作的Ani设置为不可见
|
|
ActionAnis[CurrentActionTag]->Reset();
|
|
ActionAnis[CurrentActionTag]->SetVisible(false);
|
|
|
|
// 再将新动作的Ani设置为可见
|
|
ActionAnis[actionName]->SetVisible(true);
|
|
|
|
CurrentActionTag = actionName;
|
|
}
|