http://www.plungeinteractive.com/blog/simplest-cocosbuilder-and-cocos2d-x-use-case/
The tutorial has also been linked from the wiki HOWTOs page.
Best,
JB
http://www.plungeinteractive.com/blog/simplest-cocosbuilder-and-cocos2d-x-use-case/
The tutorial has also been linked from the wiki HOWTOs page.
Best,
JB
Well done. Since c++ has no reflection, using CocosBuilder with cocos2d-x is painful. I wrote a CCBUtil.h to automate the trivial XxxLoader writing.
See my gist: https://gist.github.com/4362371
Now, If I have a GameLayer.ccbi file with the custom class named GameLayer
, I can load it as follow:
auto layer = ccb::layer(/*init params*/);
If the GameLayer has a custom member: CustomMenuItemImage, I can load it as follow:
auto layer = ccb::layer(ccb::RegisterCCNodeLoaderBlock([](CCNodeLoaderLibrary *loaderLibrary) {
ccb::registerCCNodeLoader(loaderLibrary);
})/*, other init params*/);
I also wrote some macros:
#define CCB_CCMENUITEM_SELECTOR(__CLASS__, __FUNC__) CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, #__FUNC__, __CLASS__::__FUNC__)
#define CCB_CCCONTROL_SELECTOR(__CLASS__, __FUNC__) CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, #__FUNC__, __CLASS__::__FUNC__)
to simplify:
cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName) {
CCB_CCMENUITEM_SELECTOR(GameLayer, backButtonCallback); // CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "buttonCallback", GameLayer::backButtonCallback);
return NULL;
}
cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName) {
return NULL;
};
and
#define CCB_MEMBER_VAR(__TYPE__, __VAR__) CCB_MEMBERVARIABLEASSIGNER_GLUE(this, #__VAR__, __TYPE__, __VAR__)
to simplify:
bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode) {
CCB_MEMBER_VAR(CCMenu *, _buttonMenu); // CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "_buttonMenu", CCMenu *, _buttonMenu);
return false;
}
Le Yang that’s cool, thanks for sharing