Esempio n. 1
0
void PlayLayer::explodeSushi(SushiSprite *sushi)
{
    
    // Thời gian hiệu ứng 0,3 giây
    float time = 0.3;
    
    // Thực hiện 2 hành động tuần tự, Co Sushi về kích thước, 0, 0, sau đó tự remove khỏi Contener cha
    sushi->runAction(Sequence::create(ScaleTo::create(time, 0.0),
                                      CallFuncN::create(CC_CALLBACK_1(PlayLayer::actionEndCallback, this)),NULL));
    // Action của Sprite tròn, mô phỏng vụ nổ
    
    auto circleSprite = Sprite::create("circle.png"); // Tạo mới sprite tròn
    addChild(circleSprite, 10);
    circleSprite->setPosition(sushi->getPosition()); // Vị trí = vị trí Sushi
    circleSprite->setScale(0); // Kích thước đầu =0
    // Thực hiện hành động tuần tự sau, Tăng kích thước lên tỷ lệ 1.0 trong thời gian 0,3 giây, sau đó xóa khỏi Layer
    circleSprite->runAction(Sequence::create(ScaleTo::create(time, 1.0),
                                             CallFunc::create(CC_CALLBACK_0(Sprite::removeFromParent, circleSprite)),
                                             NULL));
    
    // 3. Tạo hiệu ứng particleStars, CHÚ Ý
    
    auto particleStars = ParticleSystemQuad::create("stars.plist"); // Tạo mới
    particleStars->setAutoRemoveOnFinish(true); // Tự động remove khi xong việc
    particleStars->setBlendAdditive(false); // Thiết lập sự pha trộn thêm vào = false
    
    particleStars->setPosition(sushi->getPosition()); // Đặt vị trí tại Sushi nổ
    particleStars->setScale(0.3);  //  Thiết lập tỉ lệ 0.3
    addChild(particleStars, 20); // Thêm vào Layer Play
}
Esempio n. 2
0
		ParticleSpiralSystem() : wyQuadParticleSystem(500){
	        // duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	        // angle
	        setDirectionAngleVariance(90, 0);

	        // speed of particles
	        setSpeedVariance(150, 0);

	        // radial
	        setRadialAccelerationVariance(-380, 0);

	        // tagential
	        setTangentialAccelerationVariance(45, 0);

	        // life of particles
	        setLifeVariance(12, 0);

	        // size, in pixels
	        setStartSizeVariance(20, 0);

	        // emits per second
	        setEmissionRate(getMaxParticles() / getLife());

	        // color of particles
	        setStartColorVariance(0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.0f);
	        setEndColorVariance(0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.fire")));

	    	// additive
	    	setBlendAdditive(false);
		}
Esempio n. 3
0
bool GameComplete::init()
{
	if (!Layer::init())
	{
		return false;
	}
	auto winLabel = Label::createWithSystemFont("Game Win","Marker Felt.ttf",50);
	winLabel->setColor(Color3B::RED);
	winLabel->setPosition(Vec2(240,160));
	addChild(winLabel);

	auto mSystem = ParticleSystemQuad::create("fengye.plist");
	mSystem->setTextureWithRect(Director::getInstance()->getTextureCache()->addImage("fengye.png"),Rect(0,0,91,91));
	mSystem->setBlendAdditive(true);
	mSystem->setPosition(Vec2(240,160));
	addChild(mSystem);

	auto close = MenuItemImage::create("CloseNormal.png","CloseSelected.png");
	close->setCallback(CC_CALLBACK_1(GameComplete::menuCloseCallBack,this));
	close->setPosition(Vec2(460,20));
	 auto menu = Menu::create(close,NULL);
	 menu->setPosition(Vec2::ZERO);
	 addChild(menu,2);



	return true;
}
Esempio n. 4
0
		ParticleSmokeSystem() : wyQuadParticleSystem(200){
	        // duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	        // angle
	        setDirectionAngleVariance(90, 5);

	        // position var
	        setParticlePositionVariance(0, 0, 20, 0);

	        // life of particles
	        setLifeVariance(4, 1);

	        // speed of particles
	        setSpeedVariance(25, 10);

	        // size, in pixels
	        setStartSizeVariance(60, 10);

	        // emits per frame
	        setEmissionRate(getMaxParticles() / getLife());

	        // color of particles
	        setStartColorVariance(0.8f, 0.8f, 0.8f, 1.0f, 0.02f, 0.02f, 0.02f, 0.0f);
	        setEndColorVariance(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.fire")));

	    	// additive
	    	setBlendAdditive(false);
		}
Esempio n. 5
0
		ParticleRingSystem() : wyQuadParticleSystem(250){
	        // duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	        // angle
	        setDirectionAngleVariance(90, 360);

	        // speed of particles
	        setSpeedVariance(100, 0);

	        // radial
	        setRadialAccelerationVariance(-60, 0);

	        // tagential
	        setTangentialAccelerationVariance(15, 0);

	        // life of particles
	        setLifeVariance(10, 0);

	        // size, in pixels
	        setStartSizeVariance(30.0f, 10.0f);

	        // emits per second
	        setEmissionRate(10000);

	        // color of particles
	        setStartColorVariance(0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f);
	        setEndColorVariance(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.stars")));

	    	// additive
	    	setBlendAdditive(true);
		}
Esempio n. 6
0
void PlayLayer::explodeSushi(SushiSprite *sushi)
{
	//log("explodeSushi ture");
    float time = 0.3;
    
    // 1. action for sushi
    sushi->runAction(Sequence::create(
                                      ScaleTo::create(time, 0.0),
                                      CallFunc::create(CC_CALLBACK_0(Sprite::removeFromParent, sushi)),
                                      NULL));
	
    // 2. action for circle
    auto circleSprite = Sprite::create("circle.png");
	addChild(circleSprite, 10);
	circleSprite->setPosition(sushi->getPosition());
	circleSprite->setScale(0);// start size
    circleSprite->runAction(Sequence::create(ScaleTo::create(time, 1.0),
                                             CallFunc::create(CC_CALLBACK_0(Sprite::removeFromParent, circleSprite)),
                                             NULL));

    // 3. particle effect
	auto particleStars = ParticleSystemQuad::create("stars.plist");
    particleStars->setAutoRemoveOnFinish(true);
	particleStars->setBlendAdditive(false);
	particleStars->setPosition(sushi->getPosition());
	particleStars->setScale(0.3);
    addChild(particleStars, 20);

	//消除加分
	setScore();
}
Esempio n. 7
0
		ParticleMeteorSystem() : wyQuadParticleSystem(150) {
	        // duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	        // gravity
	        setParticleGravity(DP(-133.33f), DP(133.33f));

	        // angle
	        setDirectionAngleVariance(90, 360);

	        // speed of particles
	        setSpeedVariance(DP(10), DP(3.33f));

	        // life of particles
	        setLifeVariance(2, 1);

	        // size, in pixels
	        setStartSizeVariance(DP(40.0f), DP(6.6f));

	        // emits per second
	        setEmissionRate(getMaxParticles() / getLife());

	        // color of particles
	        setStartColorVariance(0.2f, 0.4f, 0.7f, 1.0f, 0.0f, 0.0f, 0.2f, 0.1f);
	        setEndColorVariance(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.fire")));

	    	// additive
	    	setBlendAdditive(true);
		}
Esempio n. 8
0
		ParticleFireSystem() : wyQuadParticleSystem(250){
	        // duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	        // angle
	        setDirectionAngleVariance(90, 10);

	        // life of particles
	        setLifeVariance(3.0f, 0.25f);

	        // speed of particles
	        setSpeedVariance(60, 20);

	        // size, in pixels
	        setStartSizeVariance(100.0f, 10.0f);

	        // emits per frame
	        setEmissionRate(getMaxParticles() / getLife());

	        // color of particles
	        setStartColorVariance(0.76f, 0.25f, 0.12f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
	        setEndColorVariance(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.fire")));

	    	// additive
	    	setBlendAdditive(true);
		}
Esempio n. 9
0
void GameLayer::explodeMonster(Monster *monster)
{
	float time = 0.3;
	// 1. action for Monter
	monster->runAction(Sequence::create(
		ScaleTo::create(time, 0.0),
		CallFuncN::create(CC_CALLBACK_1(GameLayer::actionEndCallback, this)),
		NULL));

	// 2. action for circle
	auto circleSprite = Sprite::create("circle.png");
	addChild(circleSprite, 10);
	circleSprite->setPosition(monster->getPosition());
	circleSprite->setScale(0);// start size
	circleSprite->runAction(Sequence::create(ScaleTo::create(time, 1.0),
		CallFunc::create(CC_CALLBACK_0(Sprite::removeFromParent, circleSprite)),
		NULL));

	// 3. particle effect
	auto particleStars = ParticleSystemQuad::create("stars.plist");
	particleStars->setAutoRemoveOnFinish(true);
	particleStars->setBlendAdditive(false);
	particleStars->setPosition(monster->getPosition());
	particleStars->setScale(0.3);
	addChild(particleStars, 20);
}
Esempio n. 10
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);

}
Esempio n. 11
0
void PlayStage::boomAnime(Point position)
{
    auto particleStars = ParticleSystemQuad::create("star_boom_ver18.plist");
    particleStars->setAutoRemoveOnFinish(true);
    particleStars->setBlendAdditive(true);
    particleStars->setScale(0.5f+chains*.1f);
    particleStars->setLife(0.2f + chains*0.02f);
    particleStars->setSpeed(400.0f + chains*20.0f);
    particleStars->setPosition(position);
    ballSheet->addChild(particleStars, 300);
}
Esempio n. 12
0
		ParticleSnowSystem() : wyQuadParticleSystem(700){
	        // duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	        // gravity
	        setParticleGravity(0, -10);

	        // angle
	        setDirectionAngleVariance(-90, 5);

	        // speed of particles
	        setSpeedVariance(130, 30);

	        // radial
	        setRadialAccelerationVariance(0, 1);

	        // tagential
	        setTangentialAccelerationVariance(0, 1);

	        // emitter position
	        setParticlePositionVariance(0, 0, wyDevice::winWidth / 2, 0);

	        // life of particles
	        setLifeVariance(3, 1);

	        // size, in pixels
	        setStartSizeVariance(10, 5);

	        // emits per second
	        setEmissionRate(getMaxParticles() / getLife());

	        // color of particles
	        setStartColorVariance(0.9f, 0.9f, 0.9f, 1.0f, 0.0f, 0.0f, 0.1f, 0.0f);
	        setEndColorVariance(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.snow")));

	    	// additive
	    	setBlendAdditive(false);
		}
Esempio n. 13
0
		ParticleRotateFlowerSystem() : wyQuadParticleSystem(50){
	    	// duration
	        setDuration(PARTICLE_DURATION_INFINITY);

	    	// Gravity mode: speed of particles
	        setSpeedVariance(160, 20);

	    	// Gravity mode: radial
	        setRadialAccelerationVariance(-120, 0);

	    	// Gravity mode: tagential
	        setTangentialAccelerationVariance(30, 0);

	    	// angle
	        setDirectionAngleVariance(90, 360);

	    	// life of particles
	        setLifeVariance(3, 1);

	    	// spin of particles
	        setEndSpinVariance(0, 2000);

	        // color of particles
	        setStartColorVariance(0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f);
	        setEndColorVariance(0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.2f);

	    	// size, in pixels
	        setStartSizeVariance(30, 0);
	        setEndSizeVariance(PARTICLE_START_SIZE_EQUAL_TO_END_SIZE, 0);

	    	// emits per second
	        setEmissionRate(getMaxParticles() / getLife());

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.stars2")));

	    	// additive
	    	setBlendAdditive(false);
		}
Esempio n. 14
0
		ParticleModernArtSystem() : wyQuadParticleSystem(1000){
			// duration
	        setDuration(PARTICLE_DURATION_INFINITY);

			// Gravity mode: radial
	        setRadialAccelerationVariance(70, 10);

			// Gravity mode: tangential
	        setTangentialAccelerationVariance(80, 0);

			// Gravity mode: speed of particles
	        setSpeedVariance(50, 10);

			// angle
	        setDirectionAngleVariance(0, 360);

			// life of particles
	        setLifeVariance(2.0f, 0.3f);

			// emits per frame
	        setEmissionRate(getMaxParticles() / getLife());

	        // color of particles
	        setStartColorVariance(0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f);
	        setEndColorVariance(0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.2f);

			// size, in pixels
	        setStartSizeVariance(1.0f, 1.0f);
	        setEndSizeVariance(32.0f, 8.0f);

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.fire")));

	    	// additive
	    	setBlendAdditive(false);
		}
Esempio n. 15
0
		ParticleFireworkSystem() : wyQuadParticleSystem(300){
			// duration
			setDuration(PARTICLE_DURATION_INFINITY);

			// gravity
			setParticleGravity(0, -90);

			// angle
			setDirectionAngleVariance(90, 20);

			// speed of particles
			setSpeedVariance(180, 50);

			// life of particles
			setLifeVariance(3.5f, 1.0f);

			// emits per frame
			setEmissionRate(getMaxParticles() / getLife());

			// color of particles
			setStartColorVariance(0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f);
			setEndColorVariance(0.1f, 0.1f, 0.1f, 0.2f, 0.1f, 0.1f, 0.1f, 0.2f);

			// size, in pixels
			setStartSizeVariance(8.0f, 2.0f);
			setEndSizeVariance(PARTICLE_START_SIZE_EQUAL_TO_END_SIZE, 0);

	    	// emits per second
	        setEmissionRate(getMaxParticles() / getLife());

	        //set texture
	        setTexture(wyTexture2D::makePNG(RES("R.drawable.fire")));

	    	// additive
	    	setBlendAdditive(false);
		}
Esempio n. 16
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));
}
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));
}
Esempio n. 19
0
Head_ParticalEffect

void addParticalToHead(Node* node)
{
	Vec2 pos[4];
	pos[0] = Vec2(5, 75);
	pos[1] = Vec2(75, 75);
	pos[2] = Vec2(75, 5);
	pos[3] = Vec2(5, 5);

	for (int i = 0; i < 2; i++)
	{
		auto   partNode = ParticleSystemQuad::createWithTotalParticles(60);
		partNode->setTexture(TextureCache::getInstance()->addImage("GameUI/CommonUI/fire.png"));//设置粒子图
		partNode->setDuration(-1);//发射时长

		// life of particles
		partNode->setLife(0.5f);//粒子生命
		partNode->setLifeVar(0.1f);

		partNode->setEmissionRate(partNode->getTotalParticles() / partNode->getLife());//发射器发射频率
		partNode->setPositionType(ParticleSystem::PositionType::FREE);//设置发射器的跟随模式

		// color of particles
		partNode->setStartColor(ccc4f(0.76f, 0.25f, 0.12f, 1.0f));//起始颜色
		partNode->setStartColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.0f));

		partNode->setEndColor(ccc4f(1.0f, 1.0f, 1.0f, 1.0f));//结束颜色
		partNode->setEndColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.1f));

		// size, in pixels
		partNode->setStartSize(15);//粒子大小
		partNode->setStartSizeVar(3);
		partNode->setEndSize(0);
		partNode->setEndSizeVar(3);

		// angle
		partNode->setAngle(0);//发射器角度
		partNode->setAngleVar(0);

		// speed of particles
		partNode->setSpeed(0);//粒子速度
		partNode->setSpeedVar(0);

		// emitter position
		partNode->setPosVar(ccp(0, 0));//发射器位置变化

		partNode->setBlendAdditive(true);

		node->addChild(partNode);
		partNode->setTag(PARTICALTAG);
		auto move0 = MoveTo::create(1.f, pos[0]);
		auto move1 = MoveTo::create(1.f, pos[1]);
		auto move2 = MoveTo::create(1.f, pos[2]);
		auto move3 = MoveTo::create(1.f, pos[3]);

		if (i == 0)
		{
			partNode->setPosition(pos[0]);
			partNode->runAction(RepeatForever::create(Sequence::create(move1, move2, move3, move0, nullptr)));
		}
		else
		{
			partNode->setPosition(pos[2]);
			partNode->runAction(RepeatForever::create(Sequence::create(move3, move0, move1, move2, nullptr)));
		}

	}
}
Esempio n. 20
0
void BaseScene::putEmitter3(Vec2 pos){
	m_emitterCreated ++;

	auto _emitter = ParticleSystemQuad::createWithTotalParticles(20);
    //_emitter->retain();
	_emitter->setTag(m_emitterCreated);

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

	_emitter->setAngleVar(360);

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

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

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

    // radial
    _emitter->setRadialAccel(-30);
    _emitter->setRadialAccelVar(-10);

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

    // emitter position
    _emitter->setPosition(pos);
    _emitter->setPosVar(Vec2::ZERO);

    // life of particles
    _emitter->setLife(1.6f);
    _emitter->setLifeVar(0.8f);

    // color of particles
	_emitter->setStartColor(C4F_(E::P.C500, 0.4f));
    _emitter->setStartColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.3f));
    _emitter->setEndColor(C4F_(E::P.C300, 0.3f));
    _emitter->setEndColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.2f));

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

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

    // additive

    _emitter->setBlendAdditive(false);
	auto cbStopEmitter = CallFunc::create([this](){m_emitterStopped++; ((ParticleSystemQuad*)this->getChildByTag(m_emitterStopped))->stopSystem();});
	auto cbRemoveEmitter = CallFunc::create([this](){m_emitterReleased++; this->getChildByTag(m_emitterReleased)->removeFromParentAndCleanup(true);});
	_emitter->runAction(Sequence::create(DelayTime::create(0.3f), cbStopEmitter, DelayTime::create(2.0f), cbRemoveEmitter, nullptr));

}