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