Connecting with cocos2d-x
如何获取cocosbuilder中的组件?
onAssignCCBMemberVariable回调成员变量
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", CCSprite *, this->mBurstSprite);
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", CCLabelTTF *, this->mTestTitleLabelTTF);
自定义属性
onAssignCCBCustomProperty回调成员变量
bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(CCObject* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue)
{
bool bRet = false;
if (pTarget == this)
{
if (0 == strcmp(pMemberVariableName, "mCustomPropertyInt"))
{
this->mCustomPropertyInt = pCCBValue->getIntValue();
CCLog("mCustomPropertyInt = %d", mCustomPropertyInt);
bRet = true;
}
else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyFloat"))
{
this->mCustomPropertyFloat = pCCBValue->getFloatValue();
CCLog("mCustomPropertyFloat = %f", mCustomPropertyFloat);
bRet = true;
}
else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyBoolean"))
{
this->mCustomPropertyBoolean = pCCBValue->getBoolValue();
CCLog("mCustomPropertyBoolean = %d", mCustomPropertyBoolean);
bRet = true;
}
else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyString"))
{
this->mCustomPropertyString = pCCBValue->getStringValue();
CCLog("mCustomPropertyString = %s", mCustomPropertyString.c_str());
bRet = true;
}
}
return bRet;
}
示例:
主页:
源码:
https://github.com/cocos2d/CocosBuilder
cocos2d网站的分页:
http://www.cocos2d-iphone.org/forum/forum/16
作者做的使用例子:
http://code.zynga.com/2012/10/creating-a-game-with-cocosbuilder/
触控的一篇blog
问题:
1.只有MAC版本
2.关联自定义类后可以自定义属性?
如果可以绑定类的话就可以实现:
2.1 继承一个CCNode的播放声音模块
2.2 继承一个CCNode的对话框模块
这样就可以基本满足cinematic的声音对话的要求。
3.v2.1支持bone动画,能支持plist动画么?
可以使用2的关联属性定义自己的CCSprite来播放动画。
4.直接拖入单图的话,引擎会自动扩展成2的幂,内存浪费,
使用plist里面集成在一张大图上的某个module。
5.如何解决屏幕尺寸适配问题?
所以位置和高宽 缩放都用相对值