Sequences and Sprites

Sprites must be able to perform two major functions:

  • Cycle through a sequence of images

  • Move about on a double buffered container

As previously mentioned, the rate at which each of these functions occurs can be set. A Sprite is responsible for moving itself about and timing its movement; however, it delegates the responsibility for cycling through a sequence of images to another object: a Sequence.

Sequence

Figure 25-1 shows the Sequence class diagram.

Figure 25-1. Sequence Class Diagram

As you can see, a Sequence maintains a vector of images that it cycles through. It also uses a stopwatch to control the rate at which it cycles ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.