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;
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class CCBAnimationManager : public Object
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
private:
|
2013-06-20 14:15:53 +08:00
|
|
|
Array *mSequences;
|
|
|
|
Dictionary *mNodeSequences;
|
|
|
|
Dictionary *mBaseValues;
|
2012-09-17 14:27:17 +08:00
|
|
|
int mAutoPlaySequenceId;
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node *mRootNode;
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Size mRootContainerSize;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCBAnimationManagerDelegate *mDelegate;
|
|
|
|
CCBSequence *mRunningSequence;
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Array *mDocumentOutletNames;
|
|
|
|
Array *mDocumentOutletNodes;
|
|
|
|
Array *mDocumentCallbackNames;
|
|
|
|
Array *mDocumentCallbackNodes;
|
|
|
|
Array *mKeyframeCallbacks;
|
|
|
|
Dictionary *mKeyframeCallFuncs;
|
2013-03-15 08:43:56 +08:00
|
|
|
|
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;
|
2013-06-20 14:15:53 +08:00
|
|
|
Object *mTarget;
|
2012-11-01 02:07:33 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Object *mOwner;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
virtual bool init();
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Array* getSequences();
|
|
|
|
void setSequences(Array* seq);
|
2012-11-22 15:15:30 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int getAutoPlaySequenceId();
|
|
|
|
void setAutoPlaySequenceId(int autoPlaySequenceId);
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* getRootNode();
|
|
|
|
void setRootNode(Node* pRootNode); // weak reference
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void addDocumentCallbackNode(Node *node);
|
2012-11-02 08:52:07 +08:00
|
|
|
void addDocumentCallbackName(std::string name);
|
2013-06-20 14:15:53 +08:00
|
|
|
void addDocumentOutletNode(Node *node);
|
2012-11-02 08:52:07 +08:00
|
|
|
void addDocumentOutletName(std::string name);
|
|
|
|
|
|
|
|
void setDocumentControllerName(const std::string &name);
|
|
|
|
|
|
|
|
std::string getDocumentControllerName();
|
2013-06-20 14:15:53 +08:00
|
|
|
Array* getDocumentCallbackNames();
|
|
|
|
Array* getDocumentCallbackNodes();
|
|
|
|
Array* getDocumentOutletNames();
|
|
|
|
Array* getDocumentOutletNodes();
|
2012-11-02 08:52:07 +08:00
|
|
|
std::string getLastCompletedSequenceName();
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Array* getKeyframeCallbacks();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
const Size& getRootContainerSize();
|
|
|
|
void setRootContainerSize(const Size &rootContainerSize);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCBAnimationManagerDelegate* getDelegate();
|
|
|
|
void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain
|
|
|
|
|
|
|
|
const char* getRunningSequenceName();
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
const Size& getContainerSize(Node* pNode);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void addNode(Node *pNode, Dictionary *pSeq);
|
|
|
|
void setBaseValue(Object *pValue, Node *pNode, const char *pPropName);
|
|
|
|
void moveAnimationsFromNode(Node* fromNode, Node* toNode);
|
2012-11-01 02:07:33 +08:00
|
|
|
|
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);
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void setAnimationCompletedCallback(Object *target, SEL_CallFunc callbackFunc);
|
2012-11-01 02:07:33 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
void debug();
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void setCallFunc(CallFunc *callFunc, const std::string &callbackNamed);
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Object* actionForCallbackChannel(CCBSequenceProperty* channel);
|
|
|
|
Object* actionForSoundChannel(CCBSequenceProperty* channel);
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
private:
|
2013-06-20 14:15:53 +08:00
|
|
|
Object* getBaseValue(Node *pNode, const char* pPropName);
|
2012-09-17 14:27:17 +08:00
|
|
|
int getSequenceId(const char* pSequenceName);
|
|
|
|
CCBSequence* getSequence(int nSequenceId);
|
2013-06-20 14:15:53 +08:00
|
|
|
ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *pPropName, Node *pNode);
|
|
|
|
void setAnimatedProperty(const char *pPropName, Node *pNode, Object *pValue, float fTweenDuraion);
|
|
|
|
void setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
|
|
|
ActionInterval* getEaseAction(ActionInterval *pAction, int nEasingType, float fEasingOpt);
|
|
|
|
void runAction(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
2012-09-17 14:27:17 +08:00
|
|
|
void sequenceCompleted();
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class CCBSetSpriteFrame : public ActionInstant
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** creates a Place action with a position */
|
2013-06-20 14:15:53 +08:00
|
|
|
static CCBSetSpriteFrame* create(SpriteFrame *pSpriteFrame);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
|
|
|
~CCBSetSpriteFrame();
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
bool initWithSpriteFrame(SpriteFrame *pSpriteFrame);
|
2013-06-16 09:54:34 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual CCBSetSpriteFrame* clone() const override;
|
|
|
|
virtual CCBSetSpriteFrame* reverse() const override;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
private:
|
|
|
|
SpriteFrame *mSpriteFrame;
|
|
|
|
};
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-03-20 06:13:00 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class CCBSoundEffect : public ActionInstant
|
2013-03-15 08:43:56 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static CCBSoundEffect* actionWithSoundFile(const std::string &file, float pitch, float pan, float gain);
|
2013-07-18 07:56:19 +08:00
|
|
|
~CCBSoundEffect();
|
2013-03-15 08:43:56 +08:00
|
|
|
bool initWithSoundFile(const std::string &file, float pitch, float pan, float gain);
|
2013-06-16 09:54:34 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual CCBSoundEffect* clone() const override;
|
|
|
|
virtual CCBSoundEffect* reverse() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string mSoundFile;
|
|
|
|
float mPitch, mPan, mGain;
|
2013-03-15 08:43:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class CCBRotateTo : public ActionInterval
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static CCBRotateTo* create(float fDuration, float fAngle);
|
|
|
|
bool initWithDuration(float fDuration, float fAngle);
|
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Override
|
|
|
|
virtual void update(float time) override;
|
|
|
|
virtual CCBRotateTo* clone() const override;
|
|
|
|
virtual CCBRotateTo* reverse() const override;
|
|
|
|
virtual void startWithTarget(Node *pNode) override;
|
2013-03-20 06:13:00 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
float mStartAngle;
|
|
|
|
float mDstAngle;
|
|
|
|
float mDiffAngle;
|
2013-07-18 07:56:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CCBRotateXTo: public ActionInterval
|
|
|
|
{
|
2013-03-20 06:13:00 +08:00
|
|
|
public:
|
2013-03-20 14:25:30 +08:00
|
|
|
static CCBRotateXTo* create(float fDuration, float fAngle);
|
|
|
|
bool initWithDuration(float fDuration, float fAngle);
|
2013-06-16 09:54:34 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual void startWithTarget(Node *pNode) override;
|
|
|
|
virtual CCBRotateXTo* clone() const override;
|
|
|
|
virtual CCBRotateXTo* reverse() const override;
|
|
|
|
virtual void update(float time) override;
|
2013-06-16 09:54:34 +08:00
|
|
|
|
2013-03-20 06:13:00 +08:00
|
|
|
private:
|
|
|
|
float mStartAngle;
|
|
|
|
float mDstAngle;
|
|
|
|
float mDiffAngle;
|
2013-07-18 07:56:19 +08:00
|
|
|
};
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
|
|
|
|
class CCBRotateYTo: public ActionInterval
|
|
|
|
{
|
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-06-16 09:54:34 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Override
|
|
|
|
virtual void startWithTarget(Node *pNode) override;
|
|
|
|
virtual CCBRotateYTo* clone() const override;
|
|
|
|
virtual CCBRotateYTo* reverse() const override;
|
|
|
|
virtual void update(float time) override;
|
2013-06-16 09:54:34 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
private:
|
|
|
|
float mStartAngle;
|
|
|
|
float mDstAngle;
|
|
|
|
float mDiffAngle;
|
2013-03-20 06:13:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class CCBEaseInstant : public ActionEase
|
2013-01-21 11:18:06 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-06-20 14:15:53 +08:00
|
|
|
static CCBEaseInstant* create(ActionInterval *pAction);
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual CCBEaseInstant* clone() const override;
|
|
|
|
virtual CCBEaseInstant* reverse() const override;
|
|
|
|
virtual void update(float dt) override;
|
2013-01-21 11:18:06 +08:00
|
|
|
};
|
|
|
|
|
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__
|