Detailed explanation of Cocos2d-x Particle System

Source: Internet
Author: User

Cocos2dx has provided us with a lot of particle system effects:

1. CCParticleExplosion explosion
2. CCParticleFire
3. CCParticleFireworks fireworks
4. CCParticleFlower
5. CCParticleGalaxy
6. CCParticleMeteor meteor
7. CCParticleRain rain
8. CCParticleSmoke snow
9. CCParticleSnow smoke
10. CCParticleSpiral spiral
11. CCParticleSun sun flame

Customize a CCParticleSystem Particle System
CCParticleSystem * ignore = CCParticleSystemQuad: create ("participant/SmallSun. plist ");
// Method 1
CCNode * parent1 = CCNode: create (); // create a node
// Method 2
CCNode * parent2 = CCParticleBatchNode: create (ignore-> getTexture ());

First:Create a CCParticleSystemQuad System: Each particle is represented by a four-point (Quad, rectangle) particle system.

CCParticleSystemQuad * emitter = CCParticleSystemQuad: create ("SmallSun. plist"); // SmallSun. plist is the file generated by the Particle System editing tool.

Second:Create a CCParticleSystemQuad System

CCParticleSystemQuad * m_emitter = new CCParticleSystemQuad ();

Std: string filename = "participant/" + "particle resource file name" + ". plist ";
M_emitter-> initWithFile (filename. c_str ());

Common settings:
Emitter1-> setStartColor (ccc4f (,); // set the particle RGBA Value
Emitter1-> setBlendAdditive (false); // whether to add a mixture
Emitter1-> setPosition (ccp (s. width/2-30, s. height/2 + 60 * neg); // you can specify the position of the emission particle.
Emitter-> setAutoRemoveOnFinish (true); // After completion, the brake is removed.

Parent1-> addChild (emitter1, 0, 1); Add the particle system to the node (you can also directly add it to a background genie CCSprite)
Layer-> addChild (parent1, 10,100 0 + I); then add it to the layer.

Common Parameters in CCParticleSystem:

// Vector of gravity and direction
CCPoint gravity;
// Speed
Float speed;
// Particle speed difference
Float speedVar;
// Tangent acceleration of Particles
Float tangentialAccel;
// Tangent acceleration Difference Between Particles
Float tangentialAccelVar;
// Radial Acceleration of Particles
Float radialAccel;
// Radial Acceleration Difference Between Particles
Float radialAccelVar;

// Particle start radius
Float startRadius;
// Start radius Difference Between Particles
Float startRadiusVar;

// Particle end radius
Float endRadius;
// Difference of the ending radius between particles
Float endRadiusVar;
// The Rotation Angle of the particle per second
Float rotatePerSecond;
// The rotation angle difference between particles per second

Float rotatePerSecondVar;


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.