#ifndef _CCB_CCBREADER_H_

#define _CCB_CCBREADER_H_

#include "cocos2d.h"

#include "ExtensionMacros.h"

#include <string>

#include <vector>

#include "CCBSequence.h"

#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \

T * ptr = new T(); \

if(ptr != NULL) { \

ptr->autorelease(); \

return ptr; \

} \

CC_SAFE_DELETE(ptr); \

return NULL; \

}

#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(T, METHOD) static T * METHOD() { \

T * ptr = new T(); \

if(ptr != NULL && ptr->init()) { \

ptr->autorelease(); \

return ptr; \

} \

CC_SAFE_DELETE(ptr); \

return NULL; \

}

#define kCCBVersion 5

enum {

kCCBPropTypePosition = 0,

kCCBPropTypeSize,

kCCBPropTypePoint,

kCCBPropTypePointLock,

kCCBPropTypeScaleLock,

kCCBPropTypeDegrees,

kCCBPropTypeInteger,

kCCBPropTypeFloat,

kCCBPropTypeFloatVar,

kCCBPropTypeCheck,

kCCBPropTypeSpriteFrame,

kCCBPropTypeTexture,

kCCBPropTypeByte,

kCCBPropTypeColor3,

kCCBPropTypeColor4FVar,

kCCBPropTypeFlip,

kCCBPropTypeBlendmode,

kCCBPropTypeFntFile,

kCCBPropTypeText,

kCCBPropTypeFontTTF,

kCCBPropTypeIntegerLabeled,

kCCBPropTypeBlock,

kCCBPropTypeAnimation,

kCCBPropTypeCCBFile,

kCCBPropTypeString,

kCCBPropTypeBlockCCControl,

kCCBPropTypeFloatScale,

kCCBPropTypeFloatXY

};

enum {

kCCBFloat0 = 0,

kCCBFloat1,

kCCBFloatMinus1,

kCCBFloat05,

kCCBFloatInteger,

kCCBFloatFull

};

enum {

kCCBPlatformAll = 0,

kCCBPlatformIOS,

kCCBPlatformMac

};

enum {

kCCBTargetTypeNone = 0,

kCCBTargetTypeDocumentRoot = 1,

kCCBTargetTypeOwner = 2,

};

enum

{

kCCBKeyframeEasingInstant,

kCCBKeyframeEasingLinear,

kCCBKeyframeEasingCubicIn,

kCCBKeyframeEasingCubicOut,

kCCBKeyframeEasingCubicInOut,

kCCBKeyframeEasingElasticIn,

kCCBKeyframeEasingElasticOut,

kCCBKeyframeEasingElasticInOut,

kCCBKeyframeEasingBounceIn,

kCCBKeyframeEasingBounceOut,

kCCBKeyframeEasingBounceInOut,

kCCBKeyframeEasingBackIn,

kCCBKeyframeEasingBackOut,

kCCBKeyframeEasingBackInOut,

};

enum

{

kCCBPositionTypeRelativeBottomLeft,

kCCBPositionTypeRelativeTopLeft,

kCCBPositionTypeRelativeTopRight,

kCCBPositionTypeRelativeBottomRight,

kCCBPositionTypePercent,

kCCBPositionTypeMultiplyResolution,

};

enum

{

kCCBSizeTypeAbsolute,

kCCBSizeTypePercent,

kCCBSizeTypeRelativeContainer,

kCCBSizeTypeHorizontalPercent,

kCCBSizeTypeVerticalPercent,

kCCBSizeTypeMultiplyResolution,

};

enum

{

kCCBScaleTypeAbsolute,

kCCBScaleTypeMultiplyResolution

};

NS_CC_EXT_BEGIN

/**

* @addtogroup cocosbuilder

* @{

*/

class CCBFile : public CCNode

{

private:

CCNode *mCCBFileNode;

public:

CCBFile();

static CCBFile* create();

CCNode* getCCBFileNode();

void setCCBFileNode(CCNode *pNode); // retain

};

/* Forward declaration. */

class CCNodeLoader;

class CCNodeLoaderLibrary;

class CCNodeLoaderListener;

class CCBMemberVariableAssigner;

class CCBSelectorResolver;

class CCBAnimationManager;

class CCData;

class CCBKeyframe;

/**

* @brief Parse CCBI file which is generated by CocosBuilder

*/

class CCBReader : public CCObject

{

private:

CCData *mData;

unsigned char *mBytes;

int mCurrentByte;

int mCurrentBit;

std::vector<std::string> mStringCache;

std::set<std::string> mLoadedSpriteSheets;

CCObject *mOwner;

CCBAnimationManager *mActionManager; //retain

CCDictionary* mActionManagers;

std::set<std::string> *mAnimatedProps;

CCNodeLoaderLibrary *mCCNodeLoaderLibrary;

CCNodeLoaderListener *mCCNodeLoaderListener;

CCBMemberVariableAssigner *mCCBMemberVariableAssigner;

CCBSelectorResolver *mCCBSelectorResolver;

std::vector<std::string> mOwnerOutletNames;

CCArray* mOwnerOutletNodes;

CCArray* mNodesWithAnimationManagers;

CCArray* mAnimationManagersForNodes;

std::vector<std::string> mOwnerCallbackNames;

CCArray* mOwnerCallbackNodes;

std::string mCCBRootPath;

bool hasScriptingOwner;

bool init();

public:

bool jsControlled;

CCBReader(CCNodeLoaderLibrary *pCCNodeLoaderLibrary, CCBMemberVariableAssigner *pCCBMemberVariableAssigner = NULL, CCBSelectorResolver *pCCBSelectorResolver
= NULL, CCNodeLoaderListener *pCCNodeLoaderListener = NULL);

CCBReader(CCBReader *pCCBReader);

virtual ~CCBReader();

CCBReader();

void setCCBRootPath(const char* pCCBRootPath);

const std::string& getCCBRootPath() const;

CCNode* readNodeGraphFromFile(const char *pCCBFileName);

CCNode* readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner);

CCNode* readNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize);

CCNode* readNodeGraphFromData(CCData *pData, CCObject *pOwner, const CCSize &parentSize);

CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName);

CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner);

CCScene* createSceneWithNodeGraphFromFile(const char *pCCBFileName, CCObject *pOwner, const CCSize &parentSize);

CCBMemberVariableAssigner* getCCBMemberVariableAssigner();

CCBSelectorResolver* getCCBSelectorResolver();

CCBAnimationManager* getAnimationManager();

void setAnimationManager(CCBAnimationManager *pAnimationManager);

// Used in CCNodeLoader::parseProperties()

std::set<std::string>* getAnimatedProperties();

std::set<std::string>& getLoadedSpriteSheet();

CCObject* getOwner();

/* Utility methods. */

static std::string lastPathComponent(const char* pString);

static std::string deletePathExtension(const char* pString);

static std::string toLowerCase(const char* pCCString);

static bool endsWith(const char* pString, const char* pEnding);

/* Parse methods. */

int readInt(bool pSigned);

unsigned char readByte();

bool readBool();

std::string readUTF8();

float readFloat();

std::string readCachedString();

bool isJSControlled();

bool readCallbackKeyframesForSeq(CCBSequence* seq);

bool readSoundKeyframesForSeq(CCBSequence* seq);

CCArray* getOwnerCallbackNames();

CCArray* getOwnerCallbackNodes();

CCArray* getOwnerOutletNames();

CCArray* getOwnerOutletNodes();

CCArray* getNodesWithAnimationManagers();

CCArray* getAnimationManagersForNodes();

CCDictionary* getAnimationManagers();

void setAnimationManagers(CCDictionary* x);  // weak reference

void addOwnerCallbackName(std::string name);

void addOwnerCallbackNode(CCNode *node);

void addDocumentCallbackName(std::string name);

void addDocumentCallbackNode(CCNode *node);

static float getResolutionScale();

static void setResolutionScale(float scale);

CCNode* readFileWithCleanUp(bool bCleanUp, CCDictionary* am);

void addOwnerOutletName(std::string name);

void addOwnerOutletNode(CCNode *node);

private:

void cleanUpNodeGraph(CCNode *pNode);

bool readSequences();

CCBKeyframe* readKeyframe(int type);

bool readHeader();

bool readStringCache();

//void readStringCacheEntry();

CCNode* readNodeGraph();

CCNode* readNodeGraph(CCNode * pParent);

bool getBit();

void alignBits();

friend class CCNodeLoader;

};

// end of effects group

/// @}

NS_CC_EXT_END

#endif


CCBReader的更多相关文章

  1. 当编译CCBReader时出现 “ CCBAnimationManager.m Use of undeclared identifier 'other‘ ” 解决方法

    第一种解决方法是去github上下载最新的CCBReader 第二种解决方法是把other替换成self.inner 建议用新版本的

  2. ‎CocosBuilder 学习笔记(1) CCBReader 解析.ccbi文件流程

    1. 简介 CocosBuilder是免费开源的Cocos2d UI编辑器. .ccb文件是CCB项目的原始文件. .ccbi文件是CCB项目发布后的生成的二进制文件.CCBReader可以快速通过该 ...

  3. 从零开始のcocos2dx生活(九)CCBReader

    NodeLoaderLibrary是用来存储节点加载器类型的类,通过registerDefaultNodeLoaders()可以注册所有默认类型的加载器 在CocosBuilder的使用手册中: 1. ...

  4. 导出 C/C++ API 给 Lua 使用[转]

    导出 C/C++ API 给 Lua 使用   cocos2d-x 和 quick-cocos2d-x 的底层代码都是使用 C++ 语言开发的.为了使用 Lua 脚本语言进行开发,我们利用 tolua ...

  5. 简单的2d图形变换--仿设变换AffineTransform

    在ios中常常遇到些小的动画效果,比如点击一个按钮后,按钮上的三角形图片就旋转了.这种简单的小动画,常常通过更改view的transform属性来实现.这个transform属性,就是一个仿射变化矩阵 ...

  6. cocosbuilder3.0使用小记

    新项目用到了堪称完美的cocos2d-x2.1.5版本,用cocsbuilder2.1版本出现了返回的最终node为null的问题,看xcode的提示说: cocos2d: WARNING! Inco ...

  7. Cocos2d-x项目移植到WP8小记

    Cocos2d-x项目移植到WP8小记 作者: K.C. 日期: 10/24/2013 Date: 2013-10-24 00:33 Title: Cocos2d-x项目移植到WP8小记 Tags: ...

  8. cocos2d-x (Android)之-那些常见的error记

    转自:http://blog.csdn.net/callchunli/article/details/8929813 (2013/9/2) build.xml:939: java.lang.Array ...

  9. cocosbuilder中使用字体描边时,字符重叠,间距过小问题

    cocosbuilder中使用字体描边时,字符重叠,间距过小问题 cocos2d-x 3.7 v3.7解析cocosbuilder中描边字体的代码如下: void LabelTTFLoader::pa ...

随机推荐

  1. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)

    #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)宏的运行机理:1. ( (TYPE *)0 ) 将零转型为TY ...

  2. POJ 2362 Square

    题意:给n个木棍,问能不能正好拼成一个正方形. 解法:POJ1011的简单版……不需要太多剪枝……随便剪一剪就好了……但是各种写屎来着QAQ 代码: #include<stdio.h> # ...

  3. java多线程学习笔记——详细

    一.线程类  1.新建状态(New):新创建了一个线程对象.        2.就绪状态(Runnable):线程对象创建后,其他线程调用了该对象的start()方法.该状态的线程位于可运行线程池中, ...

  4. Chrome的网络调试

    F12 然后

  5. LeetCode题解——Unique Path(DP与优化)

    题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  6. node-mysql中的连接池代码学习

    node-mysql是一个node.js下的mysql驱动,前段时间在处理连接池的问题上遇到了连接不释放的疑难杂症,虽已解决,但仍需总结经验避免下次重蹈覆辙.下面是node-mysql中的连接池的部分 ...

  7. VB IE 清除历史记录

    VB删除Cookie,仅适用于IE7版本 IE7版本为我们提供了命令行删除Cookie,清除临时文件缓存,清除历史记录表单的方法,下面是详细的命令运行方式. '注:以下代码仅支持IE7. '清除Int ...

  8. 转】Maven学习总结(五)——聚合与继承

    原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4058008.html 感谢! 一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1. ...

  9. Spark生态之Spark MLbase/MLlib

  10. HDU 5826 physics (积分推导)

    physics 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5826 Description There are n balls on a smoo ...