CCBAnimationManager

#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;

};

class CCBAnimationManager : public CCObject

{

private:

CCArray *mSequences;

CCDictionary *mNodeSequences;

CCDictionary *mBaseValues;

int mAutoPlaySequenceId;

CCNode *mRootNode;

CCSize mRootContainerSize;

CCBAnimationManagerDelegate *mDelegate;

CCBSequence *mRunningSequence;

CCArray *mDocumentOutletNames;

CCArray *mDocumentOutletNodes;

CCArray *mDocumentCallbackNames;

CCArray *mDocumentCallbackNodes;

CCArray *mKeyframeCallbacks;

CCDictionary *mKeyframeCallFuncs;

std::string mDocumentControllerName;

std::string lastCompletedSequenceName;

SEL_CallFunc mAnimationCompleteCallbackFunc;

CCObject *mTarget;

public:

bool jsControlled;

CCBAnimationManager();

~CCBAnimationManager();

CCObject *mOwner;

virtual bool init();

CCArray* getSequences();

void setSequences(CCArray* seq);

int getAutoPlaySequenceId();

void setAutoPlaySequenceId(int autoPlaySequenceId);

CCNode* getRootNode();

void setRootNode(CCNode* pRootNode); // weak reference

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();

CCArray* getKeyframeCallbacks();

const CCSize& getRootContainerSize();

void setRootContainerSize(const CCSize &rootContainerSize);

CCBAnimationManagerDelegate* getDelegate();

void setDelegate(CCBAnimationManagerDelegate* pDelegate); // retain

const char* getRunningSequenceName();

const CCSize& getContainerSize(CCNode* pNode);

void addNode(CCNode *pNode, CCDictionary *pSeq);

void setBaseValue(CCObject *pValue, CCNode *pNode, const char *pPropName);

void moveAnimationsFromNode(CCNode* fromNode, CCNode* toNode);

/** @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);

void setAnimationCompletedCallback(CCObject *target, SEL_CallFunc callbackFunc);

void debug();

void setCallFunc(CCCallFunc *callFunc, const std::string &callbackNamed);

CCObject* actionForCallbackChannel(CCBSequenceProperty* channel);

CCObject* actionForSoundChannel(CCBSequenceProperty* channel);

private:

CCObject* getBaseValue(CCNode *pNode, const char* pPropName);

int getSequenceId(const char* pSequenceName);

CCBSequence* getSequence(int nSequenceId);

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);

void sequenceCompleted();

};

class CCBSetSpriteFrame : public CCActionInstant

{

private:

CCSpriteFrame *mSpriteFrame;

public:

~CCBSetSpriteFrame();

/** creates a Place action with a position */

static CCBSetSpriteFrame* create(CCSpriteFrame *pSpriteFrame);

bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);

virtual void update(float time);

virtual CCObject* copyWithZone(CCZone *pZone);

};

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);

virtual CCObject* copyWithZone(CCZone *pZone);

};

class CCBRotateTo : public CCActionInterval

{

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);

virtual CCObject* copyWithZone(CCZone *pZone);

virtual void startWithTarget(CCNode *pNode);

};

class CCBRotateXTo: public CCActionInterval {

private:

float mStartAngle;

float mDstAngle;

float mDiffAngle;

public:

static CCBRotateXTo* create(float fDuration, float fAngle);

bool initWithDuration(float fDuration, float fAngle);

virtual void startWithTarget(CCNode *pNode);

virtual CCObject* copyWithZone(CCZone *pZone);

virtual void update(float time);

};

class CCBRotateYTo: public CCActionInterval {

private:

float mStartAngle;

float mDstAngle;

float mDiffAngle;

public:

static CCBRotateYTo* create(float fDuration, float fAngle);

bool initWithDuration(float fDuration, float fAngle);

virtual void startWithTarget(CCNode *pNode);

virtual CCObject* copyWithZone(CCZone *pZone);

virtual void update(float time);

};

class CCBEaseInstant : public CCActionEase

{

public:

static CCBEaseInstant* create(CCActionInterval *pAction);

virtual void update(float dt);

};

NS_CC_EXT_END

#endif // __CCB_CCBANIMATION_MANAGER_H__

时间: 2024-10-13 21:31:46

CCBAnimationManager的相关文章

SpriteBuilder 学习笔记四

Chapter 5 Timelines & Triggers SpriteBuilder的一个主要特性就是可以用关键帧创建Timeline动画.甚至可以通过提供合适的碰撞属性让静态physics body也能产生动画效果.这一章会通过使用CCBAnimationManager类创建动画效果,也会创建一个可复用的trigger node,你可以把这个trigger node放在level中,这个trigger可以让你做到当player进入trigger区域时,运行相应的代码----比如播放目标no

xcode 运行 cocos2dx 项目问题总结

由于管理公司游戏项目ios的打包,且都是cocos2dx项目.经常碰到各种各样的问题,打算以后碰到的问题记录下来... 1.这个是折腾了我挺久的一个问题 Undefined symbols for architecture armv7: "cocos2d::CCDictionary::removeObjectForKey(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator&l

改进cocos2dx中lua读ccb的方法

cocos2dx自带的CCBProxy真弱,还好提供了一个CCBReaderLoader.lua,但是也不好用, 于是修改了一下CCBReaderLoader,下面直接贴代码了. function NewCCBuilderReaderLoad(strFilePath,proxy,owner) if nil == proxy then return end --print("ccbnew") local ccbReader = proxy:createCCBReader() local

cocos2d-x 3.8 lua 关于setAnimationCompletedCallback的修改

最近想实现使用ccb动画播放攻击的时候,加点绚丽的特效,在其CCBAnimationManager类中,也找到了相对应的接口: /** * when this function bound to js ,the second param are callfunc_selector * @lua NA */ void setAnimationCompletedCallback(cocos2d::Ref *target, cocos2d::SEL_CallFunc callbackFunc) 不过可

SpriteBuilder 学习笔记八

Chapter 11 Audio and Labels 你会学到如何播放audio,包括音效和音乐(sound effects and music).sound effects可以通过Timeline播放,但是大部分都需要使用ObjectAL编程,ObjectAL是Cocos2D和SpriteBuilder使用的audio engine. 第二部分是关于Labels的------特别是,TrueType font效果. Introducing ObjectAL Cocos2D包括ObjectAL

工程使用cocosBuilder后内存相关管理总结

最近几天把查了项目的内存泄漏问题,发现了些之前没想到问题,主要是引用后cocosBuilder导致的问题. 首先说下cocos2dx里面,基本的一些内存管理原则 1.每个CCObject对象在创建时 (eg: new CCObject ()), 它的引用计数为1, 2.它是autorelease的 (大部分情况下是这样的) 会在这一帧的结束时,被autorelease掉 3.CCNode对象的析构函数,会递归调用它所有孩子及子孩子的release, 对应在addChild时它们被调用的retai

cocos2d-x-3.2 lua命名空间前缀

cc cocos核心类.Controller EventController EventListenerController.cocos扩展类(AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* EditBox$ ScrollView$ TableView$ TableViewCell$).物理引擎相关(Event(.*(Physics).*) Physics.*). c