2012-09-17 14:27:17 +08:00
|
|
|
#ifndef __CCB_CCBANIMATION_MANAGER_H__
|
|
|
|
#define __CCB_CCBANIMATION_MANAGER_H__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "ExtensionMacros.h"
|
|
|
|
#include "CCBSequence.h"
|
|
|
|
#include "CCBValue.h"
|
|
|
|
#include "CCBSequenceProperty.h"
|
|
|
|
|
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
|
|
|
class CCBAnimationManagerDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void completedAnimationSequenceNamed(const char *name) = 0;
|
|
|
|
};
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
class CCBAnimationManager : public CCObject
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
private:
|
2012-09-24 11:08:10 +08:00
|
|
|
CCArray *mSequences;
|
|
|
|
CCDictionary *mNodeSequences;
|
|
|
|
CCDictionary *mBaseValues;
|
2012-09-17 14:27:17 +08:00
|
|
|
int mAutoPlaySequenceId;
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
CCNode *mRootNode;
|
2012-09-17 14:27:17 +08:00
|
|
|
CCSize mRootContainerSize;
|
|
|
|
|
|
|
|
CCBAnimationManagerDelegate *mDelegate;
|
|
|
|
CCBSequence *mRunningSequence;
|
|
|
|
|
2012-11-01 02:07:33 +08:00
|
|
|
CCArray *mDocumentOutletNames;
|
|
|
|
CCArray *mDocumentOutletNodes;
|
|
|
|
CCArray *mDocumentCallbackNames;
|
|
|
|
CCArray *mDocumentCallbackNodes;
|
|
|
|
std::string mDocumentControllerName;
|
|
|
|
std::string lastCompletedSequenceName;
|
2012-11-02 08:52:07 +08:00
|
|
|
|
2012-11-01 02:07:33 +08:00
|
|
|
SEL_CallFunc mAnimationCompleteCallbackFunc;
|
|
|
|
CCObject *mTarget;
|
|
|
|
|
2012-11-22 15:15:30 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
public:
|
|
|
|
CCBAnimationManager();
|
|
|
|
~CCBAnimationManager();
|
|
|
|
|
|
|
|
virtual bool init();
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
CCArray* getSequences();
|
2012-11-22 15:15:30 +08:00
|
|
|
void setSequences(CCArray* seq);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int getAutoPlaySequenceId();
|
|
|
|
void setAutoPlaySequenceId(int autoPlaySequenceId);
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
CCNode* getRootNode();
|
2012-11-02 08:52:07 +08:00
|
|
|
void setRootNode(CCNode* pRootNode); // retain
|
|
|
|
|
|
|
|
|
|
|
|
void addDocumentCallbackNode(CCNode *node);
|
|
|
|
void addDocumentCallbackName(std::string name);
|
|
|
|
void addDocumentOutletNode(CCNode *node);
|
|
|
|
void addDocumentOutletName(std::string name);
|
|
|
|
|
|
|
|
void setDocumentControllerName(const std::string &name);
|
|
|
|
|
|
|
|
std::string getDocumentControllerName();
|
|
|
|
CCArray* getDocumentCallbackNames();
|
|
|
|
CCArray* getDocumentCallbackNodes();
|
|
|
|
CCArray* getDocumentOutletNames();
|
|
|
|
CCArray* getDocumentOutletNodes();
|
|
|
|
std::string getLastCompletedSequenceName();
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
const CCSize& getRootContainerSize();
|
|
|
|
void setRootContainerSize(const CCSize &rootContainerSize);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCBAnimationManagerDelegate* getDelegate();
|
|
|
|
void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain
|
|
|
|
|
|
|
|
const char* getRunningSequenceName();
|
|
|
|
|
2012-11-20 16:34:55 +08:00
|
|
|
CCSize getContainerSize(CCNode* pNode);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
void addNode(CCNode *pNode, CCDictionary *pSeq);
|
|
|
|
void setBaseValue(CCObject *pValue, CCNode *pNode, const char *pPropName);
|
2012-11-01 02:07:33 +08:00
|
|
|
void moveAnimationsFromNode(CCNode* fromNode, CCNode* toNode);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
void runAnimations(const char *pName, float fTweenDuration);
|
|
|
|
void runAnimations(const char *pName);
|
|
|
|
void runAnimations(int nSeqId, float fTweenDuraiton);
|
2012-11-01 02:07:33 +08:00
|
|
|
void setAnimationCompletedCallback(CCObject *target, SEL_CallFunc callbackFunc);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
void debug();
|
|
|
|
|
|
|
|
private:
|
2012-09-24 11:08:10 +08:00
|
|
|
CCObject* getBaseValue(CCNode *pNode, const char* pPropName);
|
2012-09-17 14:27:17 +08:00
|
|
|
int getSequenceId(const char* pSequenceName);
|
|
|
|
CCBSequence* getSequence(int nSequenceId);
|
2012-09-24 11:08:10 +08:00
|
|
|
CCActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, CCNode *pNode);
|
|
|
|
void setAnimatedProperty(const char *pPropName, CCNode *pNode, CCObject *pValue, float fTweenDuraion);
|
|
|
|
void setFirstFrame(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
|
|
|
CCActionInterval* getEaseAction(CCActionInterval *pAction, int nEasingType, float fEasingOpt);
|
|
|
|
void runAction(CCNode *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
2012-09-17 14:27:17 +08:00
|
|
|
void sequenceCompleted();
|
|
|
|
};
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
class CCBSetSpriteFrame : public CCActionInstant
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
private:
|
2012-09-24 11:08:10 +08:00
|
|
|
CCSpriteFrame *mSpriteFrame;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
~CCBSetSpriteFrame();
|
|
|
|
|
|
|
|
/** creates a Place action with a position */
|
2012-09-24 11:08:10 +08:00
|
|
|
static CCBSetSpriteFrame* create(CCSpriteFrame *pSpriteFrame);
|
|
|
|
bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
|
2012-09-17 14:27:17 +08:00
|
|
|
virtual void update(float time);
|
2012-09-24 11:08:10 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
2012-09-17 14:27:17 +08:00
|
|
|
};
|
|
|
|
|
2012-09-24 11:08:10 +08:00
|
|
|
class CCBRotateTo : public CCActionInterval
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
float mStartAngle;
|
|
|
|
float mDstAngle;
|
|
|
|
float mDiffAngle;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static CCBRotateTo* create(float fDuration, float fAngle);
|
|
|
|
bool initWithDuration(float fDuration, float fAngle);
|
|
|
|
virtual void update(float time);
|
2012-09-24 11:08:10 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
|
|
|
virtual void startWithTarget(CCNode *pNode);
|
2012-09-17 14:27:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|
|
|
|
|
|
|
|
#endif // __CCB_CCBANIMATION_MANAGER_H__
|