2012-06-13 02:59:49 +08:00
|
|
|
#include "CCSpriteLoader.h"
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
#define PROPERTY_FLIP "flip"
|
|
|
|
#define PROPERTY_DISPLAYFRAME "displayFrame"
|
|
|
|
#define PROPERTY_COLOR "color"
|
|
|
|
#define PROPERTY_OPACITY "opacity"
|
|
|
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_FLIP) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCSprite *)pNode)->setFlipX(pFlip[0]);
|
2012-09-20 11:47:45 +08:00
|
|
|
((CCSprite *)pNode)->setFlipY(pFlip[1]);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2012-06-14 06:57:33 +08:00
|
|
|
CCNodeLoader::onHandlePropTypeFlip(pNode, pParent, pPropertyName, pFlip, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCSprite *)pNode)->setColor(pCCColor3B);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCSprite *)pNode)->setOpacity(pByte);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCSprite *)pNode)->setBlendFunc(pCCBlendFunc);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
|
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|