Cocos2d is a useful game engine that can be used in Windows Phone, but it's not so good that its code can only be written in C + +.
Because of our WP application I am responsible for the implementation of particle effects, so here I introduce a variety of particle effects.
The cocos2d comes with 10 particle effects. It can be said that the general effect of the cocos2d can be used with the particle effect of the implementation. Even if we can't, we can achieve the effect we want by adjusting some properties of its own particle effect.
Here we first put out 10 kinds of particle effect implementation code
Particlerain *snow = Particlerain::create ();//the effect of rainSnow->setposition (Point ( -, -)); Snow->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Black.png"), Rect (0,0,Ten,Ten)); This-AddChild (Snow); Particleexplosion*exp = Particleexplosion::create ();//explosion effectExp->setposition (Point ( -, -)); Exp->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (exp); Particlefire*fire = Particlefire::create ();//Flame EffectFire->setposition (Point ( $, -)); Kindle->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (fire); Particlesun*sun = Particlesun::create ();//The Sun effect. The gravity of the flame effect is set to 0.Sun->setposition (Point ( -, -)); Sun->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (Sun); Particlegalaxy*ga = Particlegalaxy::create ();//Galaxy effect,Ga->setposition (Point ( -, -)); GA->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (GA); Particlesmoke*SM = Particlesmoke::create ();//the effect of smoke, slower than the flameSm->setposition (Point ( -, -)); SM->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-addChild (SM); Particlemeteor*PM = Particlemeteor::create ();//Popular EffectsPm->setposition (Point ( -, $)); PM->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (PM); Particleflower*PB = Particleflower::create ();//the effect of the flower, the personal feeling of special disorderPb->setposition (Point ( $, $)); PB->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (PB); Particlespiral*ps = Particlespiral::create ();//Spiral ShapePs->setposition (Point ( -, $)); PS->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This-AddChild (PS); Particlefireworks*PF = Particlefireworks::create ();//Fireworks EffectPf->setposition (Point ( -, $)); PF->settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,Ten,Ten)); This->addchild (PF);
The simple results can be clearly seen. are ugly.
But this is because the use of pictures is not selected and has not been adjusted.
Here are a few key attributes that can be tweaked to make the particle effect cool.
Particlemeteor *pm = Particlemeteor::create ();
Settexturewithrect (Director::getinstance ()->gettexturecache ()->addimage ("Yellow.png"), Rect (0,0,5,5));//the picture referenced by the particle and the size of the rectpm->setposition (Point (x, y));//the location that appearspm->setgravity (Point (-2,0));//Gravity settingPm->setstartsize (8.0f);//the size of the particle at the beginningPm->settotalparticles (550);//set number of particlesPm->setduration (0.5);//particle duration, in seconds
When clicked, the effect lasts for 0.5 seconds, then disappears, and the touch continues to appear for 0.5 seconds.
Introduction to C # Learning log day9--------------cocos2d-x 3.0 particle effects