修改OpenGl渲染底层之前
This commit is contained in:
39
source_game/Asset/Monster/Mon_Animation.cpp
Normal file
39
source_game/Asset/Monster/Mon_Animation.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user