2012-06-02 07:45:30 +08:00
|
|
|
#import "CCParticleSystemQuadLoader.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
using namespace cocos2d::extension;
|
|
|
|
|
|
|
|
#define PROPERTY_EMITERMODE "emitterMode"
|
|
|
|
#define PROPERTY_POSVAR "posVar"
|
|
|
|
#define PROPERTY_EMISSIONRATE "emissionRate"
|
|
|
|
#define PROPERTY_DURATION "duration"
|
|
|
|
#define PROPERTY_TOTALPARTICLES "totalParticles"
|
|
|
|
#define PROPERTY_LIFE "life"
|
|
|
|
#define PROPERTY_STARTSIZE "startSize"
|
|
|
|
#define PROPERTY_ENDSIZE "endSize"
|
|
|
|
#define PROPERTY_STARTSPIN "startSpin"
|
|
|
|
#define PROPERTY_ENDSPIN "endSpin"
|
|
|
|
#define PROPERTY_ANGLE "angle"
|
|
|
|
#define PROPERTY_STARTCOLOR "startColor"
|
|
|
|
#define PROPERTY_ENDCOLOR "endColor"
|
|
|
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
|
|
|
#define PROPERTY_GRAVITY "gravity"
|
|
|
|
#define PROPERTY_SPEED "speed"
|
|
|
|
#define PROPERTY_TANGENTIALACCEL "tangentialAccel"
|
|
|
|
#define PROPERTY_RADIALACCEL "radialAccel"
|
|
|
|
#define PROPERTY_TEXTURE "texture"
|
|
|
|
#define PROPERTY_STARTRADIUS "startRadius"
|
|
|
|
#define PROPERTY_ENDRADIUS "endRadius"
|
|
|
|
#define PROPERTY_ROTATEPERSECOND "rotatePerSecond"
|
|
|
|
|
|
|
|
CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return CCParticleSystemQuad::node();
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_EMITERMODE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setPosVar(pPoint);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setGravity(pPoint);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_EMISSIONRATE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setEmissionRate(pFloat);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_DURATION) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setDuration(pFloat);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_TOTALPARTICLES) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setTotalParticles(pInteger);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_LIFE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setLife(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_STARTSIZE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDSIZE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_STARTSPIN) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDSPIN) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ANGLE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_SPEED) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_TANGENTIALACCEL) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_RADIALACCEL) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_STARTRADIUS) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDRADIUS) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ROTATEPERSECOND) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeFloatVar(pNode, pParent, pPropertyName, pFloatVar, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setStartColor(pCCColor4FVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setStartColorVar(pCCColor4FVar[1]);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setEndColor(pCCColor4FVar[0]);
|
|
|
|
((CCParticleSystemQuad *)pNode)->setEndColorVar(pCCColor4FVar[1]);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeColor4FVar(pNode, pParent, pPropertyName, pCCColor4FVar, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setBlendFunc(pCCBlendFunc);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) {
|
2012-06-02 07:45:30 +08:00
|
|
|
((CCParticleSystemQuad *)pNode)->setTexture(pCCTexture2D);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pCCTexture2D, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|