O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required