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;
|
2013-03-15 08:43:56 +08:00
|
|
|
|
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;
|
2013-03-15 08:43:56 +08:00
|
|
|
CCArray *mKeyframeCallbacks;
|
|
|
|
CCDictionary *mKeyframeCallFuncs;
|
|
|
|
|
2012-11-01 02:07:33 +08:00
|
|
|
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:
|
2013-03-15 08:43:56 +08:00
|
|
|
bool jsControlled;
|
2012-09-17 14:27:17 +08:00
|
|
|
CCBAnimationManager();
|
|
|
|
~CCBAnimationManager();
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
CCObject *mOwner;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
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();
|
2013-01-21 14:40:29 +08:00
|
|
|
void setRootNode(CCNode* pRootNode); // weak reference
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
CCArray* getKeyframeCallbacks();
|
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();
|
|
|
|
|
2013-01-14 16:06:18 +08:00
|
|
|
const 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-11-28 11:49:20 +08:00
|
|
|
/** @deprecated This interface will be deprecated sooner or later.*/
|
|
|
|
CC_DEPRECATED_ATTRIBUTE void runAnimations(const char *pName, float fTweenDuration);
|
|
|
|
/** @deprecated This interface will be deprecated sooner or later.*/
|
|
|
|
CC_DEPRECATED_ATTRIBUTE void runAnimations(const char *pName);
|
|
|
|
/** @deprecated This interface will be deprecated sooner or later.*/
|
|
|
|
CC_DEPRECATED_ATTRIBUTE void runAnimations(int nSeqId, float fTweenDuraiton);
|
|
|
|
|
|
|
|
void runAnimationsForSequenceNamedTweenDuration(const char *pName, float fTweenDuration);
|
|
|
|
void runAnimationsForSequenceNamed(const char *pName);
|
|
|
|
void runAnimationsForSequenceIdTweenDuration(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();
|
|
|
|
|
2013-03-19 14:15:36 +08:00
|
|
|
void setCallFunc(CCCallFunc *callFunc, const std::string &callbackNamed);
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
CCObject* actionForCallbackChannel(CCBSequenceProperty* channel);
|
|
|
|
CCObject* actionForSoundChannel(CCBSequenceProperty* channel);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
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);
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
|
|
|
virtual CCBSetSpriteFrame* clone() const;
|
2012-09-24 11:08:10 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
2012-09-17 14:27:17 +08:00
|
|
|
};
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-03-20 06:13:00 +08:00
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
class CCBSoundEffect : public CCActionInstant
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string mSoundFile;
|
|
|
|
float mPitch, mPan, mGain;
|
|
|
|
|
|
|
|
public:
|
|
|
|
~CCBSoundEffect();
|
|
|
|
|
|
|
|
static CCBSoundEffect* actionWithSoundFile(const std::string &file, float pitch, float pan, float gain);
|
|
|
|
bool initWithSoundFile(const std::string &file, float pitch, float pan, float gain);
|
|
|
|
virtual void update(float time);
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
|
|
|
virtual CCBSoundEffect* clone() const;
|
2013-03-19 06:41:47 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
2013-03-15 08:43:56 +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);
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
|
|
|
virtual CCBRotateTo* clone() const;
|
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
|
|
|
};
|
|
|
|
|
2013-03-20 06:13:00 +08:00
|
|
|
|
2013-03-20 14:25:30 +08:00
|
|
|
class CCBRotateXTo: public CCActionInterval {
|
2013-03-20 06:13:00 +08:00
|
|
|
private:
|
|
|
|
float mStartAngle;
|
|
|
|
float mDstAngle;
|
|
|
|
float mDiffAngle;
|
|
|
|
public:
|
2013-03-20 14:25:30 +08:00
|
|
|
static CCBRotateXTo* create(float fDuration, float fAngle);
|
|
|
|
bool initWithDuration(float fDuration, float fAngle);
|
2013-03-20 06:13:00 +08:00
|
|
|
virtual void startWithTarget(CCNode *pNode);
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
|
|
|
virtual CCBRotateXTo* clone() const;
|
2013-03-20 14:25:30 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
2013-03-20 06:13:00 +08:00
|
|
|
virtual void update(float time);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-03-20 14:25:30 +08:00
|
|
|
class CCBRotateYTo: public CCActionInterval {
|
2013-03-20 06:13:00 +08:00
|
|
|
private:
|
|
|
|
float mStartAngle;
|
|
|
|
float mDstAngle;
|
|
|
|
float mDiffAngle;
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-03-20 06:13:00 +08:00
|
|
|
public:
|
2013-03-20 14:25:30 +08:00
|
|
|
static CCBRotateYTo* create(float fDuration, float fAngle);
|
|
|
|
bool initWithDuration(float fDuration, float fAngle);
|
2013-03-20 06:13:00 +08:00
|
|
|
virtual void startWithTarget(CCNode *pNode);
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new clone of the action */
|
|
|
|
virtual CCBRotateYTo* clone() const;
|
2013-03-20 14:25:30 +08:00
|
|
|
virtual CCObject* copyWithZone(CCZone *pZone);
|
2013-03-20 06:13:00 +08:00
|
|
|
virtual void update(float time);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-21 11:18:06 +08:00
|
|
|
class CCBEaseInstant : public CCActionEase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static CCBEaseInstant* create(CCActionInterval *pAction);
|
2013-06-16 03:38:32 +08:00
|
|
|
|
|
|
|
/** returns a new clone of the action */
|
|
|
|
virtual CCBEaseInstant* clone() const;
|
|
|
|
|
2013-01-21 11:18:06 +08:00
|
|
|
virtual void update(float dt);
|
|
|
|
};
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
NS_CC_EXT_END
|
|
|
|
|
|
|
|
#endif // __CCB_CCBANIMATION_MANAGER_H__
|