Example of Cocos2d-x3.1 particle effect
Here, we stick several effects of particles for future use.
//// IntervalLayer. cpp // testthirdone /// Created by du jia on 14-7-7. //// # include IntervalLayer. h # define SID_STEP1 100 # define SID_STEP2 101 # define SID_STEP3 102 # define IDC_PAUSE 200 bool IntervalLayer: init () {return true;} IntervalLayer: IntervalLayer () {_ time0 = _ time1 = _ time2 = _ time3 = _ time4 = 0.0f; auto s = Director: getInstance ()-> getWinSize (); auto sun = participant sun :: create (); sun-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); sun-> setPosition (Vec2 (s. width/2-100, s. height/2); sun-> settotalparticipant (130); sun-> setLife (5.0f); this-> addChild (sun); // timers auto fire = participant fire :: create (); fire-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); fire-> setPosition (Vec2 (s. width/2 + 50, s. height/2); fire-> settotaltaskles (130); fire-> setLife (5.0f); this-> addChild (fire); auto fireworks = FIG: create (); fireworks-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); fireworks-> setPosition (Vec2 (s. width/2 + 50, s. height/2-200); fireworks-> settotalparticipant (130); fireworks-> setLife (5.0f); this-> addChild (fireworks); auto galaxy = participant galaxy :: create (); galaxy-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); galaxy-> setPosition (Vec2 (50, s. height/2 + 200); galaxy-> settotalparticipant (130); galaxy-> setLife (5.0f); this-> addChild (galaxy); auto flower = participant flower :: create (); flower-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); flower-> setPosition (Vec2 (250, s. height/2 + 200); flower-> settotalparticipant (130); flower-> setLife (5.0f); this-> addChild (flower); // meteor auto meteor = MAID:: create (); meteor-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); meteor-> setPosition (Vec2 (250, 20 )); meteor-> settotalparticipant (130); meteor-> setLife (5.0f); this-> addChild (meteor); // vortex auto spiral = participant spiral: create (); spiral-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); spiral-> setPosition (Vec2 (450, 40 )); spiral-> settotalparticipant (130); spiral-> setLife (5.0f); this-> addChild (spiral); // blast auto explosion = participant explosion: create (); explosion-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); explosion-> setPosition (Vec2 (50,440 )); explosion-> settotalparticipant (130); explosion-> setLife (5.0f); this-> addChild (explosion); // smoke auto smoke = participant Moke: create (); smoke-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); smoke-> setPosition (Vec2 (450,640 )); smoke-> settotalparticipant (130); smoke-> setLife (5.0f); this-> addChild (smoke); // snow auto snow = FIG: create (); snow-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); snow-> setPosition (Vec2 (450,840 )); snow-> settotalparticipant (130); snow-> setLife (5.0f); this-> addChild (snow); // rain auto rain = FIG: create (); rain-> setTexture (Director: getInstance ()-> getTextureCache ()-> addImage(fire.png); rain-> setPosition (Vec2 (450,940 )); rain-> settotalparticipant (130); rain-> setLife (5.0f); this-> addChild (rain );}
: