mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3689 from yuye-liu/particle_designer_2
[ci skip]particle designer2.0 support
This commit is contained in:
commit
f91c29c45e
|
@ -81,7 +81,8 @@ NS_CC_BEGIN
|
||||||
//
|
//
|
||||||
|
|
||||||
ParticleSystem::ParticleSystem()
|
ParticleSystem::ParticleSystem()
|
||||||
: _isBlendAdditive(false)
|
: _configName("")
|
||||||
|
, _isBlendAdditive(false)
|
||||||
, _isAutoRemoveOnFinish(false)
|
, _isAutoRemoveOnFinish(false)
|
||||||
, _plistFile("")
|
, _plistFile("")
|
||||||
, _elapsed(0)
|
, _elapsed(0)
|
||||||
|
@ -116,6 +117,7 @@ ParticleSystem::ParticleSystem()
|
||||||
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
|
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
|
||||||
, _opacityModifyRGB(false)
|
, _opacityModifyRGB(false)
|
||||||
, _positionType(PositionType::FREE)
|
, _positionType(PositionType::FREE)
|
||||||
|
, _yCoordFlipped(0)
|
||||||
{
|
{
|
||||||
modeA.gravity = Point::ZERO;
|
modeA.gravity = Point::ZERO;
|
||||||
modeA.speed = 0;
|
modeA.speed = 0;
|
||||||
|
@ -205,6 +207,10 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
||||||
// self, not super
|
// self, not super
|
||||||
if(this->initWithTotalParticles(maxParticles))
|
if(this->initWithTotalParticles(maxParticles))
|
||||||
{
|
{
|
||||||
|
// Emitter name in particle designer 2.0
|
||||||
|
const String * configNameConstStr = dictionary->valueForKey("configName");
|
||||||
|
_configName = configNameConstStr->getCString();
|
||||||
|
|
||||||
// angle
|
// angle
|
||||||
_angle = dictionary->valueForKey("angle")->floatValue();
|
_angle = dictionary->valueForKey("angle")->floatValue();
|
||||||
_angleVar = dictionary->valueForKey("angleVariance")->floatValue();
|
_angleVar = dictionary->valueForKey("angleVariance")->floatValue();
|
||||||
|
@ -213,7 +219,14 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
||||||
_duration = dictionary->valueForKey("duration")->floatValue();
|
_duration = dictionary->valueForKey("duration")->floatValue();
|
||||||
|
|
||||||
// blend function
|
// blend function
|
||||||
_blendFunc.src = dictionary->valueForKey("blendFuncSource")->intValue();
|
if (_configName.length()>0)
|
||||||
|
{
|
||||||
|
_blendFunc.src = dictionary->valueForKey("blendFuncSource")->floatValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_blendFunc.src = dictionary->valueForKey("blendFuncSource")->intValue();
|
||||||
|
}
|
||||||
_blendFunc.dst = dictionary->valueForKey("blendFuncDestination")->intValue();
|
_blendFunc.dst = dictionary->valueForKey("blendFuncDestination")->intValue();
|
||||||
|
|
||||||
// color
|
// color
|
||||||
|
@ -284,11 +297,32 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
||||||
// or Mode B: radius movement
|
// or Mode B: radius movement
|
||||||
else if (_emitterMode == Mode::RADIUS)
|
else if (_emitterMode == Mode::RADIUS)
|
||||||
{
|
{
|
||||||
modeB.startRadius = dictionary->valueForKey("maxRadius")->floatValue();
|
if (_configName.length()>0)
|
||||||
|
{
|
||||||
|
modeB.startRadius = dictionary->valueForKey("maxRadius")->intValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modeB.startRadius = dictionary->valueForKey("maxRadius")->floatValue();
|
||||||
|
}
|
||||||
modeB.startRadiusVar = dictionary->valueForKey("maxRadiusVariance")->floatValue();
|
modeB.startRadiusVar = dictionary->valueForKey("maxRadiusVariance")->floatValue();
|
||||||
modeB.endRadius = dictionary->valueForKey("minRadius")->floatValue();
|
if (_configName.length()>0)
|
||||||
|
{
|
||||||
|
modeB.endRadius = dictionary->valueForKey("minRadius")->intValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modeB.endRadius = dictionary->valueForKey("minRadius")->floatValue();
|
||||||
|
}
|
||||||
modeB.endRadiusVar = 0.0f;
|
modeB.endRadiusVar = 0.0f;
|
||||||
modeB.rotatePerSecond = dictionary->valueForKey("rotatePerSecond")->floatValue();
|
if (_configName.length()>0)
|
||||||
|
{
|
||||||
|
modeB.rotatePerSecond = dictionary->valueForKey("rotatePerSecond")->intValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modeB.rotatePerSecond = dictionary->valueForKey("rotatePerSecond")->floatValue();
|
||||||
|
}
|
||||||
modeB.rotatePerSecondVar = dictionary->valueForKey("rotatePerSecondVariance")->floatValue();
|
modeB.rotatePerSecondVar = dictionary->valueForKey("rotatePerSecondVariance")->floatValue();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -377,6 +411,10 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
||||||
image->release();
|
image->release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_configName.length()>0)
|
||||||
|
{
|
||||||
|
_yCoordFlipped = dictionary->valueForKey("yCoordFlipped")->intValue();
|
||||||
|
}
|
||||||
CCASSERT( this->_texture != NULL, "CCParticleSystem: error loading the texture");
|
CCASSERT( this->_texture != NULL, "CCParticleSystem: error loading the texture");
|
||||||
}
|
}
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
@ -670,7 +708,21 @@ void ParticleSystem::update(float dt)
|
||||||
tmp = radial + tangential + modeA.gravity;
|
tmp = radial + tangential + modeA.gravity;
|
||||||
tmp = tmp * dt;
|
tmp = tmp * dt;
|
||||||
p->modeA.dir = p->modeA.dir + tmp;
|
p->modeA.dir = p->modeA.dir + tmp;
|
||||||
tmp = p->modeA.dir * dt;
|
if (_configName.length()>0)
|
||||||
|
{
|
||||||
|
if (_yCoordFlipped == -1)
|
||||||
|
{
|
||||||
|
tmp = p->modeA.dir * dt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp = p->modeA.dir * -dt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp = p->modeA.dir * dt;
|
||||||
|
}
|
||||||
p->pos = p->pos + tmp;
|
p->pos = p->pos + tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +735,11 @@ void ParticleSystem::update(float dt)
|
||||||
|
|
||||||
p->pos.x = - cosf(p->modeB.angle) * p->modeB.radius;
|
p->pos.x = - cosf(p->modeB.angle) * p->modeB.radius;
|
||||||
p->pos.y = - sinf(p->modeB.angle) * p->modeB.radius;
|
p->pos.y = - sinf(p->modeB.angle) * p->modeB.radius;
|
||||||
}
|
if (_yCoordFlipped == 1)
|
||||||
|
{
|
||||||
|
p->pos.y = -p->pos.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// color
|
// color
|
||||||
p->color.r += (p->deltaColor.r * dt);
|
p->color.r += (p->deltaColor.r * dt);
|
||||||
|
|
|
@ -456,6 +456,9 @@ protected:
|
||||||
//! Array of particles
|
//! Array of particles
|
||||||
tParticle *_particles;
|
tParticle *_particles;
|
||||||
|
|
||||||
|
//Emitter name
|
||||||
|
std::string _configName;
|
||||||
|
|
||||||
// color modulate
|
// color modulate
|
||||||
// BOOL colorModulate;
|
// BOOL colorModulate;
|
||||||
|
|
||||||
|
@ -540,6 +543,9 @@ protected:
|
||||||
BlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
/** does the alpha value modify color */
|
/** does the alpha value modify color */
|
||||||
bool _opacityModifyRGB;
|
bool _opacityModifyRGB;
|
||||||
|
/** does FlippedY variance of each particle */
|
||||||
|
int _yCoordFlipped;
|
||||||
|
|
||||||
|
|
||||||
/** particles movement type: Free or Grouped
|
/** particles movement type: Free or Grouped
|
||||||
@since v0.8
|
@since v0.8
|
||||||
|
|
Loading…
Reference in New Issue