// // RedreamAnim.h // redream_runtime // // Created by zhuge on 2023/1/17. // #ifndef RedreamAnim_h #define RedreamAnim_h #include "cocos2d.h" namespace redream { class REDKeyframe; class REDAnimationManager; class REDSequenceProperty; class RedreamAnim: public cocos2d::Ref { private: class PropKeyframes: public cocos2d::Ref { public: std::string propName; cocos2d::Vector keyframes; }; public: ~RedreamAnim(); static RedreamAnim* createFromAnimFile(std::string filePath); bool init(const char* filePath); public: // 编辑 void setStartPosition(cocos2d::Vec2 pos) { _startPosition = pos; } void setEndPosition(cocos2d::Vec2 pos) { _endPosition = pos; } float getDuration() { return _duration; } cocos2d::Action* getAction(); // autorelease private: REDAnimationManager* _loadAnimFile(const char* filePath); /// 給_propKeyframes初始化值 /// @param animationManager 动画属性管理器 /// @param node 唯一的动画节点 /// @param seqNodeProps 该唯一节点的每个属性的动画关键帧 void _initPropKeyframes(REDAnimationManager* animationManager, cocos2d::Node* node, cocos2d::Map& seqNodeProps); REDKeyframe* _createRedKeyframe(const cocos2d::Value& value, float atTime) const; Vec2 _getControlPoint(Vec2 A_start, Vec2 A_end, Vec2 A_control, Vec2 B_start, Vec2 B_end); Vec2 _valueToVec2(const cocos2d::Value& value); private: cocos2d::Vec2 _startPosition; cocos2d::Vec2 _endPosition; float _duration; cocos2d::Map _propKeyframes; }; }; #endif /* RedreamAnim_h */