Game Development Reference
In-Depth Information
In general, you will want to balance the emissionRate so that it matches the
particle lifetime with the totalParticles allowed in the particle effect. You can
do so by dividing totalParticles by life and set the result as the emis-
sionRate :
self.emissionRate = self.totalParticles / self.life;
Tip By tweaking particle lifetime, the total number of particles allowed in the
system, and the emissionRate , you can create burst effects by allowing the
stream of particles to be frequently interrupted just because the number of
particles onscreen is limited and new particles are emitted relatively quickly.
On the other hand, if you notice undesirable gaps in your particle stream, you
need to either increase the number of allowed particles or preferably reduce the
lifetime and/or emission rate. In that case, you should use emissionRate =
totalParticles / life .
Particle Color
Each particle can transition from a starting color to an end color, creating the vibrant
colors particle effects are known for. You should at least set the startColor in a
particle effect; otherwise, the particles may not be visible at all because the default col-
or is black. The colors are of type ccColor4F , a struct with four floating-point mem-
bers: r, g, b, and a , corresponding to the colors red, green, and blue, as well as the
alpha channel, which determines the color's opacity. The value range for each of these
members goes from 0 to 1, with 1 being the full color.
If you want a completely white particle color, you'd set all four r , g , b , and a mem-
bers to 1 . If you want a red color, you only need to set the r and a values to 1.0f . If
you want blue, then set b and a to 1.0f . Note that the a value is the alpha transparen-
cy of the color. If you leave it at the default value of 0.0f , the color will be com-
pletely translucent and thus not visible.
// startColor is mostly red and fully opaque
startColor.r = 1.0f;
startColor.g = 0.25f;
startColor.b = 0.12f;
Search Nedrilad ::




Custom Search