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

Collision Detection

Now that we've covered the Sequence, Sprite, and Playfield classes, the only topic left to discuss is collision detection. Collision detection is defined by an interface and an abstract class: CollisionArena and CollisionDetector, respectively. As we discuss collision detection, don't forget that Playfield implements CollisionArena, so everything discussed concerning CollisionArena goes for Playfield.

CollisionArena

The CollisionArena interface defines the behavior of an arena in which collisions take place, as you can see in Example 25-4.

Example 25-4. CollisionArena Interface Listing
 import java.awt.Dimension; import java.awt.Insets; ...

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