Пример #1
0
void ParticlePerformTest4::doTest()
{
    auto s = Director::getInstance()->getWinSize();
    auto particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(Vec2(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(Vec2(s.width/2, 100));
    particleSystem->setPosVar(Vec2(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife());

    // color of particles
    Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f);
    particleSystem->setStartColor(startColor);

    Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f);
    particleSystem->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f);
    particleSystem->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);   
    particleSystem->setEndColorVar(endColorVar);

    // size, in pixels
    particleSystem->setEndSize(64.0f);
    particleSystem->setStartSize(64.0f);
    particleSystem->setEndSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);

}
Пример #2
0
void TestScene::emit()
{
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(100);
    addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(1.f);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(90);
    _emitter->setAngleVar(0);

    // speed of particles
    _emitter->setSpeed(260);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(-260);
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(00);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({2,10});

    // life of particles
    _emitter->setLife(1);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(10000);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    Color4F startColor(0.f, 0.5f, 0.f, 1.0f);
    _emitter->setStartColor(startColor);

    Color4F startColorVar(0.f, 0.1f, 0.f, 1.0f);
    _emitter->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.5f, 0.1f, 1.0f);
    _emitter->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(5.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);
    //addChild(_emitter);
    _emitter->setPosition(genPos({0.5,0.5}));
    //    _emitter->runAction(RotateBy::create(10.f, 1000));
}
Пример #3
0
ParticleSystemQuad* BaseScene::createComplexParticle(int type){
	if (type == 0){
		_emitter = ParticleSystemQuad::createWithTotalParticles(50);

		addChild(_emitter, 10);

		_emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/stars.png"));

		_emitter->setDuration(-1);

		// gravity
		_emitter->setGravity(Vec2::ZERO);

		// angle
		_emitter->setAngle(90);
		_emitter->setAngleVar(360);

		// speed of particles
		_emitter->setSpeed(160);
		_emitter->setSpeedVar(20);

		// radial
		_emitter->setRadialAccel(-120);
		_emitter->setRadialAccelVar(0);

		// tagential
		_emitter->setTangentialAccel(30);
		_emitter->setTangentialAccelVar(0);

		// emitter position
		_emitter->setPosition(Vec2(160, 240));
		_emitter->setPosVar(Vec2::ZERO);

		// life of particles
		_emitter->setLife(4);
		_emitter->setLifeVar(1);

		// spin of particles
		_emitter->setStartSpin(0);
		_emitter->setStartSizeVar(0);
		_emitter->setEndSpin(0);
		_emitter->setEndSpinVar(0);

		// color of particles
		Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f);
		_emitter->setStartColor(startColor);

		Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f);
		_emitter->setStartColorVar(startColorVar);

		Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f);
		_emitter->setEndColor(endColor);

		Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);
		_emitter->setEndColorVar(endColorVar);

		// size, in pixels
		_emitter->setStartSize(80.0f);
		_emitter->setStartSizeVar(40.0f);
		_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

		// emits per second
		_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());

		// additive
		_emitter->setBlendAdditive(true);
	}
	else if (type == 1){
		_emitter = ParticleSystemQuad::createWithTotalParticles(300);
		_emitter->retain();

		addChild(_emitter, 10);
		////_emitter->release();    // win32 : Remove this line
		_emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/stars.png"));

		// duration
		_emitter->setDuration(-1);

		// gravity
		_emitter->setGravity(Vec2::ZERO);

		// angle
		_emitter->setAngle(90);
		_emitter->setAngleVar(360);

		// speed of particles
		_emitter->setSpeed(160);
		_emitter->setSpeedVar(20);

		// radial
		_emitter->setRadialAccel(-120);
		_emitter->setRadialAccelVar(0);

		// tagential
		_emitter->setTangentialAccel(30);
		_emitter->setTangentialAccelVar(0);

		// emitter position
		_emitter->setPosition(Vec2(160, 240));
		_emitter->setPosVar(Vec2::ZERO);

		// life of particles
		_emitter->setLife(3);
		_emitter->setLifeVar(1);

		// spin of particles
		_emitter->setStartSpin(0);
		_emitter->setStartSpinVar(0);
		_emitter->setEndSpin(0);
		_emitter->setEndSpinVar(2000);

		// color of particles
		Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f);
		_emitter->setStartColor(startColor);

		Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f);
		_emitter->setStartColorVar(startColorVar);

		Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f);
		_emitter->setEndColor(endColor);

		Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);
		_emitter->setEndColorVar(endColorVar);

		// size, in pixels
		_emitter->setStartSize(30.0f);
		_emitter->setStartSizeVar(00.0f);
		_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

		// emits per second
		_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());

		// additive
		_emitter->setBlendAdditive(false);
	}

	return _emitter;
}
Пример #4
0
void GameSceneQuattro::addPartcleStella(Vec2 posizione) {

	        _boom = ParticleSystemQuad::createWithTotalParticles(900);
	        _boom->setTexture(Director::getInstance()->getTextureCache()->addImage("gugut_01.png"));

	        //The code below we can use both in 2.x and 3.x
	        _boom->setDuration(-1);
	        _boom->setGravity(Point(0, -240));  // in Cocos2d-x-2.x CCPoint(0, -240) is used
	        _boom->setAngle(90);
	        _boom->setAngleVar(360);
	        _boom->setRadialAccel(50);
	        _boom->setRadialAccelVar(0);
	        _boom->setTangentialAccel(30);
	        _boom->setTangentialAccelVar(0);
	        _boom->setPosition(Point(_visibleSize.width / 2 , _visibleSize.width / 2 ));
	        _boom->setPosVar(Point(400, 0));
	        _boom->setLife(4);
	        _boom->setLifeVar(2);
	        _boom->setStartSpin(30);
	        _boom->setStartSpinVar(60);
	        _boom->setEndSpin(60);
	        _boom->setEndSpinVar(60);
	        _boom->setStartColor(Color4F(255,255,255,1));
	        _boom->setStartColorVar(Color4F(0,0,0,0));
	        _boom->setEndColor(Color4F(255, 255, 255, 1));
	        _boom->setEndColorVar(Color4F(0, 0, 0, 0));
	        _boom->setStartSize(30);
	        _boom->setStartSizeVar(0);
	        _boom->setEndSize(20.0f);
	        _boom->setEndSizeVar(0);
	        _boom->setEmissionRate(100);
	        _boom->stopSystem();
	        addChild(_boom,10);



	       _emitter = ParticleSystemQuad::createWithTotalParticles(300);
	        _emitter->retain();

	        addChild(_emitter, 15);
	        ////_emitter->release();    // win32 : Remove this line
	        _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage("star.png") );

	        // duration
	        _emitter->setDuration(-1);

	        // gravity
	        _emitter->setGravity(Vec2::ZERO);

	        // angle
	        _emitter->setAngle(90);
	        _emitter->setAngleVar(360);

	        // speed of particles
	        _emitter->setSpeed(160);
	        _emitter->setSpeedVar(20);

	        // radial
	        _emitter->setRadialAccel(-120);
	        _emitter->setRadialAccelVar(0);

	        // tagential
	        _emitter->setTangentialAccel(30);
	        _emitter->setTangentialAccelVar(0);

	        // emitter position
	        _emitter->setPosition( Vec2(160,240) );
	        _emitter->setPosVar(Vec2::ZERO);

	        // life of particles
	        _emitter->setLife(3);
	        _emitter->setLifeVar(1);

	        // spin of particles
	        _emitter->setStartSpin(0);
	        _emitter->setStartSpinVar(0);
	        _emitter->setEndSpin(0);
	        _emitter->setEndSpinVar(2000);

	        // color of particles
	        Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f);
	        _emitter->setStartColor(startColor);

	        Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f);
	        _emitter->setStartColorVar(startColorVar);

	        Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f);
	        _emitter->setEndColor(endColor);

	        Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);
	        _emitter->setEndColorVar(endColorVar);

	        // size, in pixels
	        _emitter->setStartSize(30.0f);
	        _emitter->setStartSizeVar(00.0f);
	        _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

	        // emits per second
	        _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

	        // additive
	        _emitter->setBlendAdditive(false);
	        _emitter->setPosition(Point(_visibleSize.width / 2 , _visibleSize.height / 2 ));
	        _emitter->stopSystem();




}
void FloatingEffectManager::toast_cure(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, DDElementType elementType, int level)
{

    const float speed = 300;
    float len = (desPos-srcPos).length();
    if (len == 0) {
        return;
    }
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
    _emitter->setAutoRemoveOnFinish(true);
    _layer->addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(len/speed);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(vector2angel(desPos-srcPos));
    _emitter->setAngleVar(0.5f* std::atan(DDConfig::battleCubeWidth()/len) * 180.f/3.1415926f);

    // speed of particles
    _emitter->setSpeed(speed);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(-(speed/(2*len/speed)));
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(00);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({0,0});

    // life of particles
    _emitter->setLife(2*len/speed);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(720);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    Color4F startColor(0.f, 0.5f, 0.f, 0.8f);
    _emitter->setStartColor(startColor);

    Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
    _emitter->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.5f, 0.1f, 0.8f);
    _emitter->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(3.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);

    _emitter->setPosition(srcPos);
}
void FloatingEffectManager::toast_help_tail(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, const cocos2d::Color4F& color)
{
    const float time = 0.2;
    float len = (desPos-srcPos).length();
    if (len == 0) {
        return;
    }

    const float speed = len/time;
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
    _emitter->setAutoRemoveOnFinish(true);
    _layer->addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(time*5);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(vector2angel(srcPos-desPos));
    _emitter->setAngleVar(3);

    // speed of particles
    _emitter->setSpeed(speed/5);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(0);
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(0);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({0,0});

    // life of particles
    _emitter->setLife(0.2);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(720);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    _emitter->setStartColor(color);

    Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
    _emitter->setStartColorVar(startColorVar);

    _emitter->setEndColor(color);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(2.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);
    
    _emitter->setPosition(srcPos);
    _emitter->runAction(MoveTo::create(0.1, desPos));
}