Game Development Reference
In-Depth Information
Once the CGGradientRef is created, call CGContextDrawLinearGradient . It would normally fill the
entire UIView with the specified gradient, but because we specified the clip region at the top of the
task, we get a nice circle with the gradient evenly drawn over it.
We have looked at how we can create actors that are drawn using Core Graphics to open up the
possibility of dynamically drawing our actors, preventing us from having to create an image for every
possible state of our actors. In the next section, we will look at another strategy for drawing actors,
those based on particles.
Adding Particle Systems to Your Game
Particle systems in games are collections of many, usually small, images drawn together to create an
7-3 shows this next example in action.
Figure 7-3. Comets and destructible asteroids
In Figure 7-3 , we see three comets traveling across the screen. We also see a number of asteroids in
various states of exploding. The asteroids drift in from off the screen, and when you tap the screen
they explode into a number of smaller asteroids. In addition to creating the new, smaller asteroids,
we send out a number of particles that look like asteroids. This gives the destruction of the larger
asteroid some added realism because big chunks of rock seldom break cleanly into smaller pieces.
These two different particle effects, the comets and the asteroid debris, are very different, but
 
Search WWH ::




Custom Search