mirror of https://github.com/axmolengine/axmol.git
Added rotationIsDir to Particle System. It sets the rotation of each particle to its direction
This commit is contained in:
parent
ba111316a7
commit
5c915fc584
|
@ -124,6 +124,7 @@ CCParticleSystem::CCParticleSystem()
|
||||||
modeA.tangentialAccelVar = 0;
|
modeA.tangentialAccelVar = 0;
|
||||||
modeA.radialAccel = 0;
|
modeA.radialAccel = 0;
|
||||||
modeA.radialAccelVar = 0;
|
modeA.radialAccelVar = 0;
|
||||||
|
modeA.rotationIsDir = false;
|
||||||
modeB.startRadius = 0;
|
modeB.startRadius = 0;
|
||||||
modeB.startRadiusVar = 0;
|
modeB.startRadiusVar = 0;
|
||||||
modeB.endRadius = 0;
|
modeB.endRadius = 0;
|
||||||
|
@ -277,6 +278,9 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary, const char *
|
||||||
// tangential acceleration
|
// tangential acceleration
|
||||||
modeA.tangentialAccel = dictionary->valueForKey("tangentialAcceleration")->floatValue();
|
modeA.tangentialAccel = dictionary->valueForKey("tangentialAcceleration")->floatValue();
|
||||||
modeA.tangentialAccelVar = dictionary->valueForKey("tangentialAccelVariance")->floatValue();
|
modeA.tangentialAccelVar = dictionary->valueForKey("tangentialAccelVariance")->floatValue();
|
||||||
|
|
||||||
|
// rotation is dir
|
||||||
|
modeA.rotationIsDir = dictionary->valueForKey("rotationIsDir")->boolValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// or Mode B: radius movement
|
// or Mode B: radius movement
|
||||||
|
@ -544,6 +548,9 @@ void CCParticleSystem::initParticle(tCCParticle* particle)
|
||||||
// tangential accel
|
// tangential accel
|
||||||
particle->modeA.tangentialAccel = modeA.tangentialAccel + modeA.tangentialAccelVar * CCRANDOM_MINUS1_1();
|
particle->modeA.tangentialAccel = modeA.tangentialAccel + modeA.tangentialAccelVar * CCRANDOM_MINUS1_1();
|
||||||
|
|
||||||
|
// rotation is dir
|
||||||
|
if(modeA.rotationIsDir)
|
||||||
|
particle->rotation = -CC_RADIANS_TO_DEGREES(ccpToAngle(particle->modeA.dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mode Radius: B
|
// Mode Radius: B
|
||||||
|
@ -897,6 +904,18 @@ float CCParticleSystem::getRadialAccelVar()
|
||||||
return modeA.radialAccelVar;
|
return modeA.radialAccelVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCParticleSystem::setRotationIsDir(bool t)
|
||||||
|
{
|
||||||
|
CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity");
|
||||||
|
modeA.rotationIsDir = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CCParticleSystem::getRotationIsDir()
|
||||||
|
{
|
||||||
|
CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity");
|
||||||
|
return modeA.rotationIsDir;
|
||||||
|
}
|
||||||
|
|
||||||
void CCParticleSystem::setGravity(const CCPoint& g)
|
void CCParticleSystem::setGravity(const CCPoint& g)
|
||||||
{
|
{
|
||||||
CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity");
|
CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity");
|
||||||
|
|
|
@ -196,6 +196,8 @@ protected:
|
||||||
float radialAccel;
|
float radialAccel;
|
||||||
/** radial acceleration variance of each particle. Only available in 'Gravity' mode. */
|
/** radial acceleration variance of each particle. Only available in 'Gravity' mode. */
|
||||||
float radialAccelVar;
|
float radialAccelVar;
|
||||||
|
/** set the rotation of each particle to its direction Only available in 'Gravity' mode. */
|
||||||
|
bool rotationIsDir
|
||||||
} modeA;
|
} modeA;
|
||||||
|
|
||||||
//! Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode)
|
//! Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode)
|
||||||
|
@ -277,6 +279,8 @@ public:
|
||||||
virtual void setRadialAccel(float t);
|
virtual void setRadialAccel(float t);
|
||||||
virtual float getRadialAccelVar();
|
virtual float getRadialAccelVar();
|
||||||
virtual void setRadialAccelVar(float t);
|
virtual void setRadialAccelVar(float t);
|
||||||
|
virtual bool getRotationIsDir();
|
||||||
|
virtual void setRotationIsDir(bool t);
|
||||||
// mode B
|
// mode B
|
||||||
virtual float getStartRadius();
|
virtual float getStartRadius();
|
||||||
virtual void setStartRadius(float startRadius);
|
virtual void setStartRadius(float startRadius);
|
||||||
|
@ -375,7 +379,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static CCParticleSystem * create(const char *plistFile);
|
static CCParticleSystem * create(const char *plistFile);
|
||||||
|
|
||||||
//! create a system with a fixed number of particles
|
//! create a system with a fixed number of particles
|
||||||
static CCParticleSystem* createWithTotalParticles(unsigned int numberOfParticles);
|
static CCParticleSystem* createWithTotalParticles(unsigned int numberOfParticles);
|
||||||
|
|
||||||
/** initializes a CCParticleSystem*/
|
/** initializes a CCParticleSystem*/
|
||||||
|
|
Loading…
Reference in New Issue