2dx解析cocosbuilder中使用layer时的缺陷
cocos2d-x 3.7
cocosbuilder中的layer通常会用到触摸属性:
#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);
}
}