Game Development Reference
In-Depth Information
startColor.a = 1.0f;
// startColor has no variance (plus/minus 0.0f)
startColorVar.r = 0.0f;
startColorVar.g = 0.0f;
startColorVar.b = 0.0f;
startColorVar.a = 0.0f;
// endColor is a fully opaque black color
endColor.r = 0.0f;
endColor.g = 0.0f;
endColor.b = 0.0f;
endColor.a = 1.0f;
// endColorVar specifies a full variance range for color blue
// the end of lifetime color of a particle will be randomly between black and blue
endColorVar.r = 0.0f;
endColorVar.g = 0.0f;
endColorVar.b = 1.0f;
endColorVar.a = 0.0f;
Particle Blend Mode
Blending refers to the computation a particle's pixels go through before being dis-
played onscreen. The property blendFunc takes a ccBlendFunc struct as in-
put, which provides the source and destination blend modes:
self.blendFunc = (ccBlendFunc){GL_SRC_ALPHA, GL_DST_ALPHA};
Blending works by taking the red, green, blue, and alpha of the source image (the
particle) and mixing it with the colors of any images that are already onscreen when the
particle is rendered. In effect, the particle blends in a certain way with its background,
and blendFunc determines how much and what colors of the source image are blen-
ded with how much and with which colors of the background.
The formula to determine the final pixel color onscreen is as follows:
(source color * source blend function) + (destination color * destination blend function)
Let's assume your example source pixel has the RGB values (0.1, 0.2, 0.3), and the
destination pixel has the RGB values (0.4, 0.5, 0.6). Both color values are multiplied
Search Nedrilad ::




Custom Search