Until this example, the particles simply vanished from the scene when their duration expired. A nice
effect is to have the particles slowly fade with age, as shown in Figure 2-5. This produces a more natural
look, as the eye does not notice each individual particle vanishing.
Figure 2-5. Example 3, fading
When running the example, the slider labeled “Particle Opacity” controls the starting opacity of
each particle. The checkbox labeled “Fade Out” controls whether or not the particles will fade at the end
of their lives. The code in Listing 2-7 shows how to add these two transparency features to the particles.
■ Note While this text uses the word transparency to describe nodes that can be seen through, the actual
attribute on the class Node is called opacity. Opacity is simply the opposite of transparency, so an opacity value of
1.0 has no transparency and an opacity value of 0.2 is mostly transparent.