Пример #1
0
void showStarParticleEffect(int color,Point position,Node* node){
	CCLOG("Particle Particle Particle");
	ParticleExplosion* effect = ParticleExplosion::create();
	effect->setTexture(Director::getInstance()->getTextureCache()->addImage("star.png"));
	effect->setTotalParticles(300);
	effect->setStartColor(getColor4F(color));
	effect->setStartColorVar(Color4F(0,0,0,1));
	effect->setEndColor(getColor4F(color));
	effect->setEndColorVar(Color4F(0,0,0,1));
	effect->setStartSize(25.0f);	// 初始化粒子元素的尺寸
	effect->setGravity(Point(0,-400));
	effect->setDuration(0.2f);
	effect->setLife(2.0f);
	effect->setSpeed(300.0f);
	effect->setSpeedVar(10);
	effect->setPosition(position);
	node->addChild(effect);
}
void WelcomeScene::particleEffect(Point pos)
{

	ParticleExplosion* effect = ParticleExplosion::create();
	effect->setTexture(Director::getInstance()->getTextureCache()->addImage("victoryMenu.png"));
	effect->setTotalParticles(10);

	//让其为图片本身的颜色
	effect->setStartColor(Color4F(255, 255, 255, 255));
	effect->setEndColor(Color4F(255, 255, 255, 0));

	effect->setStartSize(50.0f);

	effect->setLife(2.6f);
	effect->setSpeed(200);
	effect->setSpeedVar(10);
	effect->setPosition(pos);
	start->addChild(effect, 15);
}