- 将翻转逻辑集中到Animation类中处理 - 添加spriteFrameOffsets_存储帧偏移量 - 改进角色动画方向切换时的表现 - 移除CharacterAnimation中的ApplyFlipRecursive方法 - 优化动画帧位置和旋转的计算方式
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "character/CharacterDataLoader.h"
|
|
#include "character/CharacterEquipmentManager.h"
|
|
#include <frostbite2D/2d/actor.h>
|
|
#include <frostbite2D/animation/animation.h>
|
|
#include <frostbite2D/base/RefPtr.h>
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace frostbite2D {
|
|
|
|
class CharacterObject;
|
|
|
|
class CharacterAnimation : public Actor {
|
|
public:
|
|
using ActionAnimationList = std::map<std::string, std::vector<RefPtr<Animation>>>;
|
|
|
|
bool Init(CharacterObject* parent,
|
|
const character::CharacterConfig& config,
|
|
const CharacterEquipmentManager& equipmentManager);
|
|
|
|
void SetAction(const std::string& actionName);
|
|
void SetDirection(int direction);
|
|
const std::string& GetCurrentAction() const { return currentActionTag_; }
|
|
bool HasAction(const std::string& actionName) const {
|
|
return actionAnimations_.count(actionName) > 0;
|
|
}
|
|
|
|
private:
|
|
static std::string FormatImgPath(std::string path, Animation::ReplaceData data);
|
|
|
|
void CreateAnimationBySlot(const std::string& actionName,
|
|
const std::string& slotName,
|
|
const std::string& actionPath,
|
|
const character::CharacterConfig& config,
|
|
const CharacterEquipmentManager& equipmentManager);
|
|
|
|
CharacterObject* parent_ = nullptr;
|
|
ActionAnimationList actionAnimations_;
|
|
std::string currentActionTag_;
|
|
int direction_ = 1;
|
|
};
|
|
|
|
} // namespace frostbite2D
|