1、CCSkeletonAnimation:继承自CCSkeleton,骨骼动画类
class CC_EX_DLL CCSkeletonAnimation: public CCSkeleton { public: std::vector<AnimationState*> states; //状态容器 static CCSkeletonAnimation* createWithData (SkeletonData* skeletonData); //相关创建函数 static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1); static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1); CCSkeletonAnimation (SkeletonData* skeletonData); CCSkeletonAnimation (const char* skeletonDataFile, Atlas* atlas, float scale = 1); CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 1); virtual ~CCSkeletonAnimation (); virtual void update (float deltaTime); void addAnimationState (AnimationStateData* stateData = 0); //两个添加状态函数 void setAnimationStateData (AnimationStateData* stateData, int stateIndex = 0); void setMix (const char* fromAnimation, const char* toAnimation, float duration, int stateIndex = 0); void setAnimation (const char* name, bool loop, int stateIndex = 0); //设置动画 void addAnimation (const char* name, bool loop, float delay = 0, int stateIndex = 0); //添加 void clearAnimation (int stateIndex = 0); //清除 protected: CCSkeletonAnimation (); private: typedef CCSkeleton super; std::vector<AnimationStateData*> stateDatas; void initialize (); };2、CCSkeleton:继承自CCNodeRGBA和CCBlendProtocol,骨骼处理类
class CC_EX_DLL CCSkeleton: public cocos2d::CCNodeRGBA, public cocos2d::CCBlendProtocol { public: Skeleton* skeleton; Bone* rootBone; float timeScale; bool debugSlots; bool debugBones; bool premultipliedAlpha; static CCSkeleton* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false); static CCSkeleton* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1); static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1); CCSkeleton (SkeletonData* skeletonData, bool ownsSkeletonData = false); CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale = 1); CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 1); virtual ~CCSkeleton (); virtual void update (float deltaTime); //更新 virtual void draw (); //绘制 virtual cocos2d::CCRect boundingBox (); //获得包围体 void updateWorldTransform (); //更新世界变换 void setToSetupPose (); void setBonesToSetupPose (); void setSlotsToSetupPose (); Bone* findBone (const char* boneName) const; //查找骨骼 Slot* findSlot (const char* slotName) const; bool setSkin (const char* skinName); //设置皮肤 Attachment* getAttachment (const char* slotName, const char* attachmentName) const; bool setAttachment (const char* slotName, const char* attachmentName); CC_PROPERTY(cocos2d::ccBlendFunc, blendFunc, BlendFunc); virtual void setOpacityModifyRGB (bool value); virtual bool isOpacityModifyRGB (); protected: CCSkeleton (); void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData); cocos2d::CCTextureAtlas* getTextureAtlas (RegionAttachment* regionAttachment) const; private: bool ownsSkeletonData; Atlas* atlas; void initialize (); };3、AnimationState:动画状态结构体
typedef struct { AnimationStateData* const data; Animation* const animation; float time; int/*bool*/loop; } AnimationState;4、AnimationStateData:动画数据结构体
typedef struct { SkeletonData* const skeletonData; const void* const entries; } AnimationStateData;5、SkeletonData:骨骼数据结构体
typedef struct { int boneCount; BoneData** bones; int slotCount; SlotData** slots; int skinCount; Skin** skins; Skin* defaultSkin; int animationCount; Animation** animations; } SkeletonData;
Cocos2d-x结构学习(十七)CCSkeletonAnimation、CCSkeleton、AnimationState、AnimationState、SkeletonData
原文地址:http://blog.csdn.net/a809146548/article/details/44702477