修复
This commit is contained in:
@@ -385,6 +385,7 @@ void GameMap::Enter()
|
||||
|
||||
void GameMap::OnUpdate(float deltaTime)
|
||||
{
|
||||
Actor::OnUpdate(deltaTime);
|
||||
|
||||
RefPtr<GameCamera> Cam = Global_Game::GetInstance().GetCamera();
|
||||
if (Cam == nullptr)
|
||||
@@ -431,7 +432,6 @@ void GameMap::OnUpdate(float deltaTime)
|
||||
Layer.second->SetPosition(posX, posY);
|
||||
}
|
||||
|
||||
Actor::OnUpdate(deltaTime);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,26 +25,26 @@ void GameWorld::Exit()
|
||||
void GameWorld::Init()
|
||||
{
|
||||
// RefPtr<Animation> ani = new Animation("common/tuguan/maineff.ani");
|
||||
RefPtr<Sprite> sp = new Sprite("sprite/live/else/chn/2022/0510_danjin_jar/22_danjineft/0510_danjin_body.img",0);
|
||||
RefPtr<AnimationMap> am = new AnimationMap();
|
||||
// am->AddAnimation(ani);
|
||||
am->AddChild(sp);
|
||||
am->CompleteConstruction();
|
||||
AddChild(am);
|
||||
// RefPtr<Sprite> sp = new Sprite("sprite/live/else/chn/2022/0510_danjin_jar/22_danjineft/0510_danjin_body.img",0);
|
||||
// RefPtr<AnimationMap> am = new AnimationMap();
|
||||
// // am->AddAnimation(ani);
|
||||
// am->AddChild(sp);
|
||||
// am->CompleteConstruction();
|
||||
// AddChild(am);
|
||||
|
||||
// // 构造所有城镇
|
||||
// auto &GlobalGame = Global_Game::GetInstance();
|
||||
// for (auto obj : GlobalGame.GetTownMap())
|
||||
// {
|
||||
// RefPtr<GameTown> town = new GameTown;
|
||||
// town->Init(obj.first);
|
||||
// m_TownMap[obj.first] = town;
|
||||
// }
|
||||
// 构造所有城镇
|
||||
auto &GlobalGame = Global_Game::GetInstance();
|
||||
for (auto obj : GlobalGame.GetTownMap())
|
||||
{
|
||||
RefPtr<GameTown> town = new GameTown;
|
||||
town->Init(obj.first);
|
||||
m_TownMap[obj.first] = town;
|
||||
}
|
||||
|
||||
// // 构造角色
|
||||
// RefPtr<CharacterObject> obj = new CharacterObject();
|
||||
// obj->Construction(0);
|
||||
// AddCharacter(obj, 1);
|
||||
// 构造角色
|
||||
RefPtr<CharacterObject> obj = new CharacterObject();
|
||||
obj->Construction(0);
|
||||
AddCharacter(obj, 1);
|
||||
}
|
||||
|
||||
void GameWorld::AddCharacter(RefPtr<CharacterObject> Chr, int TownId)
|
||||
|
||||
@@ -40,7 +40,7 @@ void CharacterObject::DisableController()
|
||||
|
||||
void CharacterObject::ControllerMsg(CONTROLLER_MSG_TYPE msgType, void *msgData)
|
||||
{
|
||||
// 摇杆移动(左)
|
||||
// 摇杆移动
|
||||
if (msgType == CONTROLLER_MSG_TYPE::CONTROLLER_MSG_TYPE_LEFT_JOYSTICK_MOVE)
|
||||
{
|
||||
Vec2 *pos = (Vec2 *)msgData;
|
||||
|
||||
@@ -26,16 +26,17 @@ void Chr_Animation::CreateSkinmationBySlot(std::string actionName, std::string s
|
||||
if (Equip)
|
||||
{
|
||||
Animation::ReplaceData Data(0, 0);
|
||||
|
||||
for (auto &Variation : Equip->JobAni[this->chr_parent->Job])
|
||||
{
|
||||
Data.Param1 = Variation.ImgFormat[0];
|
||||
Data.Param2 = Variation.ImgFormat[1];
|
||||
// 构造Ani
|
||||
// 构造好Ani以后 统一设置为不可见 然后放入ActionAnis表
|
||||
RefPtr<Animation> Ani = new Animation(path, FormatImgPath, Data);
|
||||
Ani->SetVisible(false);
|
||||
|
||||
Ani->SetZOrder(Variation.Layer);
|
||||
// 将构造好的Ani 添加进AniMap
|
||||
ActionAnis[actionName]->AddAnimation(Ani);
|
||||
this->AddChild(Ani);
|
||||
ActionAnis[actionName].push_back(Ani);
|
||||
|
||||
// 构造一下阴影对象 //TODO
|
||||
// RefPtr<Animation> ShadowAni = new Animation(path, FormatImgPath, Data);
|
||||
@@ -51,6 +52,7 @@ void Chr_Animation::CreateSkinmationBySlot(std::string actionName, std::string s
|
||||
RefPtr<Equipment> Equip = ((CharacterObject *)GetParent())->_EquipmentManager->GetEquip(slotName);
|
||||
if (Equip)
|
||||
{
|
||||
// SDL_Log("CreateSkinmationBySlot %s", slotName.c_str());
|
||||
Animation::ReplaceData Data(0, 0);
|
||||
for (auto &Variation : Equip->JobAni[this->chr_parent->Job])
|
||||
{
|
||||
@@ -62,11 +64,12 @@ void Chr_Animation::CreateSkinmationBySlot(std::string actionName, std::string s
|
||||
// 组装动画路径
|
||||
std::string AniPath = EquipPath + Variation.AnimationGroup + path.substr(path.find_last_of("/"), path.length());
|
||||
|
||||
// 构造Ani
|
||||
// 构造好Ani以后 统一设置为不可见 然后放入ActionAnis表
|
||||
RefPtr<Animation> Ani = new Animation(AniPath, FormatImgPath, Data);
|
||||
Ani->SetVisible(false);
|
||||
Ani->SetZOrder(Variation.Layer);
|
||||
// 将构造好的Ani 添加进AniMap
|
||||
ActionAnis[actionName]->AddAnimation(Ani);
|
||||
this->AddChild(Ani);
|
||||
ActionAnis[actionName].push_back(Ani);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +77,7 @@ void Chr_Animation::CreateSkinmationBySlot(std::string actionName, std::string s
|
||||
|
||||
void Chr_Animation::Init(CharacterObject *parent)
|
||||
{
|
||||
// 调用RenderBase类的初始化 才能挂上标签
|
||||
parent->AddChild(this);
|
||||
chr_parent = parent;
|
||||
GlobalCharacterScript::CharacterConfig Config = Global_Game::GetInstance().CharacterConfigs[parent->Job];
|
||||
@@ -84,20 +88,12 @@ void Chr_Animation::Init(CharacterObject *parent)
|
||||
std::string ActionName = pair.first;
|
||||
std::string Path = std::string("character/" + Config.jobTag + "/" + Tool_toLowerCase(pair.second));
|
||||
|
||||
//以动作为Key构造AniMap
|
||||
ActionAnis[ActionName] = new AnimationMap();
|
||||
ActionAnis[ActionName]->SetVisible(false);
|
||||
|
||||
// 遍历所有时装部位构造Ani
|
||||
for (auto &AvatarPartPair : AvatarPart)
|
||||
{
|
||||
std::string AvatarPartName = AvatarPartPair.first;
|
||||
CreateSkinmationBySlot(ActionName, AvatarPartName, Path);
|
||||
}
|
||||
|
||||
// 将所有时装部位的Ani添加到动作AniMap以后完成构造
|
||||
ActionAnis[ActionName]->CompleteConstruction();
|
||||
this->AddChild(ActionAnis[ActionName]);
|
||||
}
|
||||
// 设置初始动作
|
||||
SetAction("rest");
|
||||
@@ -106,9 +102,18 @@ void Chr_Animation::Init(CharacterObject *parent)
|
||||
void Chr_Animation::SetAction(std::string actionName)
|
||||
{
|
||||
// 先将原动作的Ani设置为不可见
|
||||
ActionAnis[CurrentActionTag]->Reset();
|
||||
ActionAnis[CurrentActionTag]->SetVisible(false);
|
||||
// 再将新动作的Ani设置为可见
|
||||
ActionAnis[actionName]->SetVisible(true);
|
||||
CurrentActionTag = actionName;
|
||||
for (auto Ani : ActionAnis[CurrentActionTag])
|
||||
{
|
||||
Ani->Reset();
|
||||
Ani->SetVisible(false);
|
||||
}
|
||||
// 再将新动作的Ani设置为可见
|
||||
for (auto Ani : ActionAnis[actionName])
|
||||
{
|
||||
Ani->SetVisible(true);
|
||||
}
|
||||
CurrentActionTag = actionName;
|
||||
|
||||
// 设置阴影的动作
|
||||
// if(chr_parent->_Shadow)chr_parent->_Shadow->SetAction(actionName);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Base/Actor.h"
|
||||
#include "EngineFrame/Component/AnimationMap.h"
|
||||
#include "EngineFrame/Component/Animation.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
@@ -8,7 +7,7 @@ class CharacterObject;
|
||||
class Chr_Animation : public Actor
|
||||
{
|
||||
// 动作动画集合
|
||||
using ActionAniList = std::map<std::string, RefPtr<AnimationMap>>;
|
||||
using ActionAniList = std::map<std::string, std::vector<RefPtr<Animation>>>;
|
||||
|
||||
public:
|
||||
inline static const std::unordered_map<std::string, std::string>
|
||||
|
||||
Reference in New Issue
Block a user