Forums » Extensions and Tools » How to use CCBReader in cocos2d-x 2.0.1 »
| game Programmer | How to use CCBReader in cocos2d-x 2.0.1 | ||||
|---|---|---|---|---|---|
|
Added by game Programmer 10 months ago
In older version , Now the same thing in new version which is inside the extension folder It is not working ? What mistake is happening while initialising ? Thanks for the help |
||||
| James Chen | RE: How to use CCBReader in cocos2d-x 2.0.1 | ||||
|
Added by James Chen 10 months ago
What's the error? |
||||
| JP Sarda | RE: How to use CCBReader in cocos2d-x 2.0.1 | ||||
|
I'm trying the same thing, the node returned is null and there is no error message in the traces. As far as I'm concerned the problem I have is a bad access because I have a CCMenuItemImage in my ccb node. Maybe there's a pb with CCMenuItemImage, I'll try to remove them. |
||||
| JP Sarda | RE: How to use CCBReader in cocos2d-x 2.0.1 | ||||
|
There is a problem with CCMenuItemImage when the target and selector are left empty. I made a small fix in the file CCMenuItemLoader.h :
void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_BLOCK) == 0) {
if (pBlockData!=NULL) { //Added this if test to allow CCMenuItemImage without target/selector predefined
((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler);
}
} else {
CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader);
}
}
Here is the code that works for me (cocosBuilder v2.0 RC1 + cocos2d-2.0-rc2-x-2.0.1 @ Jun 29 2012) :
cocos2d::extension::CCNodeLoaderLibrary * ccNodeLoaderLibrary = cocos2d::extension::CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary(); //newDefaultCCNodeLoaderLibrary();
cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
CCNode * node = ccbReader->readNodeGraphFromFile("", "tests.ccbi", this);
this->addChild(node);
|
||||
| lin miao | RE: How to use CCBReader in cocos2d-x 2.0.1 | ||||
|
I can't add a CCControlButton in cocosBuilder v2.0 RC1. If I add it, cocos2d-2.0-rc2-x-2.0.1 will be have a Assertion failed when it load a ccbi file. |
||||
| Milda Genius | RE: How to use CCBReader in cocos2d-x 2.0.1 | ||||
|
Added by Milda Genius 10 months ago
lin miao: |
||||
| Zhe Wang | RE: How to use CCBReader in cocos2d-x 2.0.1 | ||||
|
@JP Sarda, Thanks for your contribution. I merged your improvement in http://github.com/cocos2d/cocos2d-x/pull/1138 Enjoy Coding, Enjoy Life. |
(1-6/6)