cocos2d-x 3.7
cocosbuilder中的layer通常会用到触摸属性:
但是在2dx解析布局文件的时候,却很多属性都没解析:
#define PROPERTY_touch_ENABLED "istouchEnabled"#define PROPERTY_ACCELEROMETER_ENABLED "isAccelerometerEnabled"#define PROPERTY_MOUSE_ENABLED "isMouseEnabled"#define PROPERTY_KEYBOARD_ENABLED "isKeyboardEnabled"voID LayerLoader::onHandlePropTypeCheck(Node * pNode,Node * pParent,const char * pPropertyname,bool pCheck,CCBReader * ccbReader) { if(strcmp(pPropertyname,PROPERTY_touch_ENABLED) == 0) { ((Layer *)pNode)->settouchEnabled(pCheck); } else if(strcmp(pPropertyname,PROPERTY_ACCELEROMETER_ENABLED) == 0) { ((Layer *)pNode)->setAccelerometerEnabled(pCheck); } else if(strcmp(pPropertyname,PROPERTY_MOUSE_ENABLED) == 0) { // Todo: Not supported cclOG("The property '%s' is not supported!",PROPERTY_MOUSE_ENABLED); } else if(strcmp(pPropertyname,PROPERTY_KEYBOARD_ENABLED) == 0) { // Todo: Not supported cclOG("The property '%s' is not supported!",PROPERTY_KEYBOARD_ENABLED); // This comes closest: ((Layer *)pNode)->setKeypadEnabled(pCheck); } else { NodeLoader::onHandlePropTypeCheck(pNode,pParent,pPropertyname,pCheck,ccbReader); }}
最常用的ONE_BY_ONE和Swallowstouches都没有解析,这样使用cocosbuilder编辑的那些属性还有什么用呢
下面是修改后的解析函数:
#define PROPERTY_DONT_touch_SWALLOW "donttouchSwallow"#define PROPERTY_touch_ONE_BY_ONE "touchOneByOne"#define PROPERTY_touch_ENABLED "touchEnabled"#define PROPERTY_ACCELEROMETER_ENABLED "accelerometerEnabled"#define PROPERTY_MOUSE_ENABLED "mouseEnabled"#define PROPERTY_KEYBOARD_ENABLED "keyboardEnabled"voID LayerLoader::onHandlePropTypeCheck(Node * pNode,PROPERTY_DONT_touch_SWALLOW) == 0) { ((Layer *)pNode)->setSwallowstouches(!pCheck); } else if(strcmp(pPropertyname,PROPERTY_touch_ONE_BY_ONE) == 0) { ((Layer *)pNode)->settouchMode(touch::dispatchMode::ONE_BY_ONE); } else if(strcmp(pPropertyname,PROPERTY_KEYBOARD_ENABLED) == 0) { ((Layer *)pNode)->setKeyboardEnabled(pCheck); } else { NodeLoader::onHandlePropTypeCheck(pNode,ccbReader); }}总结
以上是内存溢出为你收集整理的2dx解析cocosbuilder中使用layer时的缺陷全部内容,希望文章能够帮你解决2dx解析cocosbuilder中使用layer时的缺陷所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)