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.radialAccel = 0;
|
||||
modeA.radialAccelVar = 0;
|
||||
modeA.rotationIsDir = false;
|
||||
modeB.startRadius = 0;
|
||||
modeB.startRadiusVar = 0;
|
||||
modeB.endRadius = 0;
|
||||
|
@ -277,6 +278,9 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary, const char *
|
|||
// tangential acceleration
|
||||
modeA.tangentialAccel = dictionary->valueForKey("tangentialAcceleration")->floatValue();
|
||||
modeA.tangentialAccelVar = dictionary->valueForKey("tangentialAccelVariance")->floatValue();
|
||||
|
||||
// rotation is dir
|
||||
modeA.rotationIsDir = dictionary->valueForKey("rotationIsDir")->boolValue();
|
||||
}
|
||||
|
||||
// or Mode B: radius movement
|
||||
|
@ -544,6 +548,9 @@ void CCParticleSystem::initParticle(tCCParticle* particle)
|
|||
// tangential accel
|
||||
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
|
||||
|
@ -897,6 +904,18 @@ float CCParticleSystem::getRadialAccelVar()
|
|||
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)
|
||||
{
|
||||
CCAssert( m_nEmitterMode == kCCParticleModeGravity, "Particle Mode should be Gravity");
|
||||
|
|
|
@ -196,6 +196,8 @@ protected:
|
|||
float radialAccel;
|
||||
/** radial acceleration variance of each particle. Only available in 'Gravity' mode. */
|
||||
float radialAccelVar;
|
||||
/** set the rotation of each particle to its direction Only available in 'Gravity' mode. */
|
||||
bool rotationIsDir
|
||||
} modeA;
|
||||
|
||||
//! 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 float getRadialAccelVar();
|
||||
virtual void setRadialAccelVar(float t);
|
||||
virtual bool getRotationIsDir();
|
||||
virtual void setRotationIsDir(bool t);
|
||||
// mode B
|
||||
virtual float getStartRadius();
|
||||
virtual void setStartRadius(float startRadius);
|
||||
|
@ -375,7 +379,7 @@ public:
|
|||
*/
|
||||
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);
|
||||
|
||||
/** initializes a CCParticleSystem*/
|
||||
|
|
Loading…
Reference in New Issue