Game Development Reference
In-Depth Information
classes CCSprite , CCSpriteBatchNode , CCLabelTTF , CCLayerCo-
lor , and CCLayerGradient .
The source and target blend modes GL_SRC_ALPHA and GL_ONE are frequently com-
bined to create additive blending, resulting in very bright or even white colors where
many particles are drawn on top of each other:
self.blendFunc = (ccBlendFunc){GL_SRC_ALPHA, GL_ONE};
Alternatively, you can simply set the blendAdditive property to YES , which is the
same as setting blendFunc to GL_SRC_ALPHA and GL_ONE :
self.blendAdditive = YES;
The normal blend mode is set using GL_SRC_ALPHA and
GL_ONE_MINUS_SRC_ALPHA , which creates transparent particles:
self.blendFunc = (ccBlendFunc){GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA};
Particle Texture
Without a texture, all particles would be flat, colored squares, as in Figure 9-3 . To use a
texture for a particle effect, provide one using the CCTextureCache method ad-
dImage , which returns the CCTexture2D for the given image file:
self.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.png"];
Particle textures look best if they're cloudlike and roughly spherical. It's often detri-
mental to the particle effect if the texture has high-contrast areas, resembling a particu-
lar shape or form, like the redcross.png from the shoot-'em-up game. This makes
it easier to see individual particles because they don't blend too well with each other.
Some effects can use this to their advantage, like the aforementioned stars circling the
player's head. In addition, cartoonlike images or gradients work best, whereas
photorealistic images tend to create an undefinable pixel mess. To demonstrate this,
Figure 9-6 shows three different textures applied to the same particle effect.
Search Nedrilad ::

Custom Search