2012-06-13 02:59:49 +08:00
|
|
|
#include "CCScale9SpriteLoader.h"
|
2012-05-31 07:52:02 +08:00
|
|
|
|
2012-09-24 11:47:33 +08:00
|
|
|
|
2012-05-31 07:52:02 +08:00
|
|
|
|
|
|
|
#define PROPERTY_CONTENTSIZE "contentSize"
|
2012-06-01 03:38:00 +08:00
|
|
|
#define PROPERTY_SPRITEFRAME "spriteFrame"
|
2012-05-31 07:52:02 +08:00
|
|
|
#define PROPERTY_COLOR "color"
|
|
|
|
#define PROPERTY_OPACITY "opacity"
|
|
|
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
2012-06-01 03:38:00 +08:00
|
|
|
#define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder!
|
|
|
|
#define PROPERTY_INSETLEFT "insetLeft"
|
|
|
|
#define PROPERTY_INSETTOP "insetTop"
|
|
|
|
#define PROPERTY_INSETRIGHT "insetRight"
|
|
|
|
#define PROPERTY_INSETBOTTOM "insetBottom"
|
2012-05-31 07:52:02 +08:00
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_SPRITEFRAME) == 0) {
|
2013-04-05 23:58:23 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setSpriteFrame(pCCSpriteFrame);
|
2012-05-31 07:52:02 +08:00
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
2012-05-31 07:52:02 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setColor(pCCColor3B);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) {
|
2012-05-31 07:52:02 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setOpacity(pByte);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
2012-05-31 07:52:02 +08:00
|
|
|
// TODO Not exported by CocosBuilder yet!
|
|
|
|
// ((CCScale9Sprite *)pNode)->setBlendFunc(pCCBlendFunc);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) {
|
2012-06-01 03:38:00 +08:00
|
|
|
//((CCScale9Sprite *)pNode)->setContentSize(pSize);
|
2012-11-26 21:51:05 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) {
|
2012-06-01 03:38:00 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setPreferredSize(pSize);
|
2012-05-31 07:52:02 +08:00
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
|
|
|
|
}
|
2012-06-01 03:38:00 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_INSETLEFT) == 0) {
|
2012-06-01 03:38:00 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setInsetLeft(pFloat);
|
2012-11-26 21:51:05 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_INSETTOP) == 0) {
|
2012-06-01 03:38:00 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setInsetTop(pFloat);
|
2012-11-26 21:51:05 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_INSETRIGHT) == 0) {
|
2012-06-01 03:38:00 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setInsetRight(pFloat);
|
2012-11-26 21:51:05 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_INSETBOTTOM) == 0) {
|
2012-06-01 03:38:00 +08:00
|
|
|
((CCScale9Sprite *)pNode)->setInsetBottom(pFloat);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader);
|
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
2013-04-05 23:58:23 +08:00
|
|
|
NS_CC_EXT_END
|