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
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
if(pSpriteFrame != NULL) {
|
|
|
|
((Sprite *)pNode)->setDisplayFrame(pSpriteFrame);
|
2013-05-08 05:52:11 +08:00
|
|
|
} else {
|
|
|
|
CCLOG("ERROR: SpriteFrame NULL");
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void SpriteLoader::onHandlePropTypeFlip(Node * pNode, Node * pParent, const char * pPropertyName, bool * pFlip, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_FLIP) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((Sprite *)pNode)->setFlipX(pFlip[0]);
|
|
|
|
((Sprite *)pNode)->setFlipY(pFlip[1]);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeFlip(pNode, pParent, pPropertyName, pFlip, ccbReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((Sprite *)pNode)->setColor(pColor3B);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void SpriteLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((Sprite *)pNode)->setOpacity(pByte);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((Sprite *)pNode)->setBlendFunc(pBlendFunc);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pBlendFunc, ccbReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|