2012-06-13 02:59:49 +08:00
|
|
|
#include "CCLayerGradientLoader.h"
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
USING_NS_CC_EXT;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
#define PROPERTY_STARTCOLOR "startColor"
|
|
|
|
#define PROPERTY_ENDCOLOR "endColor"
|
|
|
|
#define PROPERTY_STARTOPACITY "startOpacity"
|
|
|
|
#define PROPERTY_ENDOPACITY "endOpacity"
|
|
|
|
#define PROPERTY_VECTOR "vector"
|
|
|
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
|
|
|
|
|
|
|
CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return CCLayerGradient::node();
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCLayerGradient *)pNode)->setStartColor(pCCColor3B);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCLayerGradient *)pNode)->setEndColor(pCCColor3B);
|
|
|
|
} else {
|
|
|
|
CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_STARTOPACITY) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCLayerGradient *)pNode)->setStartOpacity(pByte);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDOPACITY) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCLayerGradient *)pNode)->setEndOpacity(pByte);
|
|
|
|
} else {
|
|
|
|
CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCLayerGradientLoader::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
|
|
|
((CCLayerGradient *)pNode)->setBlendFunc(pCCBlendFunc);
|
|
|
|
} else {
|
|
|
|
CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
((CCLayerGradient *)pNode)->setVector(pPoint);
|
|
|
|
|
|
|
|
// TODO Not passed along the ccbi file.
|
|
|
|
// ((CCLayerGradient *)pNode)->setIsCompressedInterpolation(true);
|
|
|
|
} else {
|
|
|
|
CCLayerLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|