Exercising the Animation Package

When creating animations are created with using the animation package, Playfield is typically extended and spriteCollision() and edgeCollision() are overridden in order to handle sprite-on-sprite and sprite-boundary collisions, respectively. The only other coding necessary is to create the sprites and their associated sequences, define the sprites initial location and move vector, and add them to the playfield.

Simple Animation

To start off, we'll look at a simple animation applet that you can use as a starting point for your own animations. Our simple animation has one instance of Sprite that bounces off the walls of the Playfield. Figure 25-4 shows the applet, but of course, you can see the full animation by ...

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.