bool ParticleSmoke::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Emitter mode: Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Vec2(0,0)); // Gravity Mode: radial acceleration setRadialAccel(0); setRadialAccelVar(0); // Gravity Mode: speed of particles setSpeed(25); setSpeedVar(10); // angle _angle = 90; _angleVar = 5; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Vec2(winSize.width/2, 0)); setPosVar(Vec2(20, 0)); // life of particles _life = 4; _lifeVar = 1; // size, in pixels _startSize = 60.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per frame _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.8f; _startColor.g = 0.8f; _startColor.b = 0.8f; _startColor.a = 1.0f; _startColorVar.r = 0.02f; _startColorVar.g = 0.02f; _startColorVar.b = 0.02f; _startColorVar.a = 0.0f; _endColor.r = 0.0f; _endColor.g = 0.0f; _endColor.b = 0.0f; _endColor.a = 1.0f; _endColorVar.r = 0.0f; _endColorVar.g = 0.0f; _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; }
bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = 0.1f; setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); // Gravity Mode: speed of particles setSpeed(70); setSpeedVar(40); // Gravity Mode: radial setRadialAccel(0); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(0); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 360; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Point(winSize.width/2, winSize.height/2)); setPosVar(Point::ZERO); // life of particles _life = 5.0f; _lifeVar = 2; // size, in pixels _startSize = 15.0f; _startSizeVar = 10.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_duration; // color of particles _startColor.r = 0.7f; _startColor.g = 0.1f; _startColor.b = 0.2f; _startColor.a = 1.0f; _startColorVar.r = 0.5f; _startColorVar.g = 0.5f; _startColorVar.b = 0.5f; _startColorVar.a = 0.0f; _endColor.r = 0.5f; _endColor.g = 0.5f; _endColor.b = 0.5f; _endColor.a = 0.0f; _endColorVar.r = 0.5f; _endColorVar.g = 0.5f; _endColorVar.b = 0.5f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != NULL) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; }
bool ParticleSpiral::initWithTotalParticles(int numberOfParticles) { if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration _duration = DURATION_INFINITY; // Gravity Mode setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Vec2(0,0)); // Gravity Mode: speed of particles setSpeed(150); setSpeedVar(0); // Gravity Mode: radial setRadialAccel(-380); setRadialAccelVar(0); // Gravity Mode: tangential setTangentialAccel(45); setTangentialAccelVar(0); // angle _angle = 90; _angleVar = 0; // emitter position Size winSize = Director::getInstance()->getWinSize(); this->setPosition(Vec2(winSize.width/2, winSize.height/2)); setPosVar(Vec2::ZERO); // life of particles _life = 12; _lifeVar = 0; // size, in pixels _startSize = 20.0f; _startSizeVar = 0.0f; _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; // color of particles _startColor.r = 0.5f; _startColor.g = 0.5f; _startColor.b = 0.5f; _startColor.a = 1.0f; _startColorVar.r = 0.5f; _startColorVar.g = 0.5f; _startColorVar.b = 0.5f; _startColorVar.a = 0.0f; _endColor.r = 0.5f; _endColor.g = 0.5f; _endColor.b = 0.5f; _endColor.a = 1.0f; _endColorVar.r = 0.5f; _endColorVar.g = 0.5f; _endColorVar.b = 0.5f; _endColorVar.a = 0.0f; Texture2D* texture = getDefaultTexture(); if (texture != nullptr) { setTexture(texture); } // additive this->setBlendAdditive(false); return true; } return false; }