feat(animation): 添加动画状态回调支持
refactor(character): 重构角色动作处理逻辑 feat(swordman): 实现剑士基础攻击和技能1处理 refactor(state): 优化状态机与动作上下文管理 feat(input): 改进输入系统支持动作请求队列 refactor(movement): 重构移动系统支持行走/奔跑模式
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <frostbite2D/2d/actor.h>
|
||||
#include <frostbite2D/animation/animation.h>
|
||||
#include <frostbite2D/base/RefPtr.h>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -16,6 +17,8 @@ class CharacterObject;
|
||||
class CharacterAnimation : public Actor {
|
||||
public:
|
||||
using ActionAnimationList = std::map<std::string, std::vector<RefPtr<Animation>>>;
|
||||
using ActionFrameFlagCallback = std::function<void(int)>;
|
||||
using ActionEndCallback = std::function<void()>;
|
||||
|
||||
bool Init(CharacterObject* parent,
|
||||
const character::CharacterConfig& config,
|
||||
@@ -28,9 +31,19 @@ public:
|
||||
return actionAnimations_.count(actionName) > 0;
|
||||
}
|
||||
std::string DescribeAvailableActions() const;
|
||||
bool IsCurrentActionFinished() const;
|
||||
int GetCurrentFrameIndex() const;
|
||||
int GetCurrentFrameCount() const;
|
||||
float GetCurrentNormalizedProgress() const;
|
||||
animation::AniFrame GetCurrentFrameInfo() const;
|
||||
void SetActionFrameFlagCallback(ActionFrameFlagCallback callback);
|
||||
void SetActionEndCallback(ActionEndCallback callback);
|
||||
|
||||
private:
|
||||
static std::string FormatImgPath(std::string path, Animation::ReplaceData data);
|
||||
Animation* GetPrimaryAnimation(const std::string& actionName) const;
|
||||
Animation* GetCurrentPrimaryAnimation() const;
|
||||
void RefreshRuntimeCallbacks();
|
||||
|
||||
void CreateAnimationBySlot(const std::string& actionName,
|
||||
const std::string& slotName,
|
||||
@@ -42,6 +55,8 @@ private:
|
||||
ActionAnimationList actionAnimations_;
|
||||
std::string currentActionTag_;
|
||||
int direction_ = 1;
|
||||
ActionFrameFlagCallback actionFrameFlagCallback_;
|
||||
ActionEndCallback actionEndCallback_;
|
||||
};
|
||||
|
||||
} // namespace frostbite2D
|
||||
|
||||
Reference in New Issue
Block a user