2012-09-17 14:27:17 +08:00
|
|
|
#ifndef __CCB_CCBANIMATION_MANAGER_H__
|
|
|
|
#define __CCB_CCBANIMATION_MANAGER_H__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "extensions/ExtensionMacros.h"
|
2012-09-17 14:27:17 +08:00
|
|
|
#include "CCBSequence.h"
|
|
|
|
#include "CCBValue.h"
|
|
|
|
#include "CCBSequenceProperty.h"
|
2013-10-15 18:00:03 +08:00
|
|
|
#include "extensions/GUI/CCControlExtension/CCControl.h"
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocosbuilder {
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
class CCBAnimationManagerDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void completedAnimationSequenceNamed(const char *name) = 0;
|
|
|
|
};
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBAnimationManager : public cocos2d::Object
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-27 21:44:49 +08:00
|
|
|
bool _jsControlled;
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2012-09-17 14:27:17 +08:00
|
|
|
CCBAnimationManager();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2012-09-17 14:27:17 +08:00
|
|
|
~CCBAnimationManager();
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Object *_owner;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
virtual bool init();
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Array* getSequences();
|
|
|
|
void setSequences(cocos2d::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-10-15 18:00:03 +08:00
|
|
|
cocos2d::Node* getRootNode();
|
|
|
|
void setRootNode(cocos2d::Node* pRootNode); // weak reference
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
void addDocumentCallbackNode(cocos2d::Node *node);
|
2012-11-02 08:52:07 +08:00
|
|
|
void addDocumentCallbackName(std::string name);
|
2013-10-15 18:00:03 +08:00
|
|
|
void addDocumentCallbackControlEvents(cocos2d::extension::Control::EventType eventType);
|
2013-08-12 11:18:07 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
void addDocumentOutletNode(cocos2d::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-10-15 18:00:03 +08:00
|
|
|
cocos2d::Array* getDocumentCallbackNames();
|
|
|
|
cocos2d::Array* getDocumentCallbackNodes();
|
|
|
|
cocos2d::Array* getDocumentCallbackControlEvents();
|
2013-08-12 11:18:07 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Array* getDocumentOutletNames();
|
|
|
|
cocos2d::Array* getDocumentOutletNodes();
|
2012-11-02 08:52:07 +08:00
|
|
|
std::string getLastCompletedSequenceName();
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Array* getKeyframeCallbacks();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
const cocos2d::Size& getRootContainerSize();
|
|
|
|
void setRootContainerSize(const cocos2d::Size &rootContainerSize);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCBAnimationManagerDelegate* getDelegate();
|
|
|
|
void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain
|
|
|
|
|
|
|
|
const char* getRunningSequenceName();
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
const cocos2d::Size& getContainerSize(cocos2d::Node* pNode);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
void addNode(cocos2d::Node *pNode, cocos2d::Dictionary *pSeq);
|
|
|
|
void setBaseValue(cocos2d::Object *pValue, cocos2d::Node *pNode, const char *propName);
|
|
|
|
void moveAnimationsFromNode(cocos2d::Node* fromNode, cocos2d::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-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* when this function bound to js ,the second param are callfunc_selector
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
void setAnimationCompletedCallback(cocos2d::Object *target, cocos2d::SEL_CallFunc callbackFunc);
|
2012-11-01 02:07:33 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
void debug();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js setCallFuncForJSCallbackNamed
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
void setCallFunc(cocos2d::CallFunc *callFunc, const std::string &callbackNamed);
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Object* actionForCallbackChannel(CCBSequenceProperty* channel);
|
|
|
|
cocos2d::Object* actionForSoundChannel(CCBSequenceProperty* channel);
|
2013-08-05 10:23:41 +08:00
|
|
|
|
|
|
|
// return -1 if timeline not exsit
|
|
|
|
int getSequenceId(const char* pSequenceName);
|
|
|
|
|
|
|
|
// get timeline duration
|
|
|
|
float getSequenceDuration(const char* pSequenceName);
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
private:
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Object* getBaseValue(cocos2d::Node *pNode, const char* propName);
|
2012-09-17 14:27:17 +08:00
|
|
|
CCBSequence* getSequence(int nSequenceId);
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *propName, cocos2d::Node *pNode);
|
|
|
|
void setAnimatedProperty(const char *propName,cocos2d::Node *pNode, Object *pValue, float fTweenDuraion);
|
|
|
|
void setFirstFrame(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
|
|
|
cocos2d::ActionInterval* getEaseAction(cocos2d::ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt);
|
|
|
|
void runAction(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
2012-09-17 14:27:17 +08:00
|
|
|
void sequenceCompleted();
|
2013-07-27 22:31:57 +08:00
|
|
|
|
|
|
|
private:
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Array *_sequences;
|
|
|
|
cocos2d::Dictionary *_nodeSequences;
|
|
|
|
cocos2d::Dictionary *_baseValues;
|
2013-07-27 22:31:57 +08:00
|
|
|
int _autoPlaySequenceId;
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Node *_rootNode;
|
2013-07-27 22:31:57 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Size _rootContainerSize;
|
2013-07-27 22:31:57 +08:00
|
|
|
|
|
|
|
CCBAnimationManagerDelegate *_delegate;
|
|
|
|
CCBSequence *_runningSequence;
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::Array *_documentOutletNames;
|
|
|
|
cocos2d::Array *_documentOutletNodes;
|
|
|
|
cocos2d::Array *_documentCallbackNames;
|
|
|
|
cocos2d::Array *_documentCallbackNodes;
|
|
|
|
cocos2d::Array *_documentCallbackControlEvents;
|
|
|
|
cocos2d::Array *_keyframeCallbacks;
|
|
|
|
cocos2d::Dictionary *_keyframeCallFuncs;
|
2013-07-27 22:31:57 +08:00
|
|
|
|
|
|
|
std::string _documentControllerName;
|
|
|
|
std::string _lastCompletedSequenceName;
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::SEL_CallFunc _animationCompleteCallbackFunc;
|
|
|
|
cocos2d::Object *_target;
|
2012-09-17 14:27:17 +08:00
|
|
|
};
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBSetSpriteFrame : public cocos2d::ActionInstant
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** creates a Place action with a position */
|
2013-10-15 18:00:03 +08:00
|
|
|
static CCBSetSpriteFrame* create(cocos2d::SpriteFrame *pSpriteFrame);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
~CCBSetSpriteFrame();
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
bool initWithSpriteFrame(cocos2d::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:
|
2013-10-15 18:00:03 +08:00
|
|
|
cocos2d::SpriteFrame *_spriteFrame;
|
2013-07-18 07:56:19 +08:00
|
|
|
};
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-03-20 06:13:00 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBSoundEffect : public cocos2d::ActionInstant
|
2013-03-15 08:43:56 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static CCBSoundEffect* actionWithSoundFile(const std::string &file, float pitch, float pan, float gain);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
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:
|
2013-07-27 22:31:57 +08:00
|
|
|
std::string _soundFile;
|
|
|
|
float _pitch, _pan, _gain;
|
2013-03-15 08:43:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBRotateTo : public cocos2d::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;
|
2013-10-15 18:00:03 +08:00
|
|
|
virtual void startWithTarget(cocos2d::Node *pNode) override;
|
2013-03-20 06:13:00 +08:00
|
|
|
|
|
|
|
private:
|
2013-07-27 22:31:57 +08:00
|
|
|
float _startAngle;
|
|
|
|
float _dstAngle;
|
|
|
|
float _diffAngle;
|
2013-07-18 07:56:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBRotateXTo: public cocos2d::ActionInterval
|
2013-07-18 07:56:19 +08:00
|
|
|
{
|
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
|
2013-10-15 18:00:03 +08:00
|
|
|
virtual void startWithTarget(cocos2d::Node *pNode) override;
|
2013-07-18 07:56:19 +08:00
|
|
|
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:
|
2013-07-27 22:31:57 +08:00
|
|
|
float _startAngle;
|
|
|
|
float _dstAngle;
|
|
|
|
float _diffAngle;
|
2013-07-18 07:56:19 +08:00
|
|
|
};
|
2013-06-16 03:38:32 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBRotateYTo: public cocos2d::ActionInterval
|
2013-07-18 07:56:19 +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-06-16 09:54:34 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Override
|
2013-10-15 18:00:03 +08:00
|
|
|
virtual void startWithTarget(cocos2d::Node *pNode) override;
|
2013-07-18 07:56:19 +08:00
|
|
|
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:
|
2013-07-27 22:31:57 +08:00
|
|
|
float _startAngle;
|
|
|
|
float _dstAngle;
|
|
|
|
float _diffAngle;
|
2013-03-20 06:13:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
class CCBEaseInstant : public cocos2d::ActionEase
|
2013-01-21 11:18:06 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-10-15 18:00:03 +08:00
|
|
|
static CCBEaseInstant* create(cocos2d::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
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
#endif // __CCB_CCBANIMATION_MANAGER_H__
|