Game Development Reference
Detecting collisions with the bounding box
How does Flash actually know that two objects are touching? All display objects (objects you can see
on the stage) are surrounded by imaginary rectangular boxes called bounding boxes. The bounding
box defines the area of the object that depPaopK^fa_p checks for a collision. The bounding box is usu-
ally invisible, but you can see it when you select an object on the stage by clicking it once, as shown
in Figure 7-20.
Figure 7-20. Examples of bounding boxes
A collision is detected whenever any portion of the bounding box intersects with any portion of
another object's bounding box. Figure 7-21 shows some examples.
Figure 7-21. Collisions are detected when bounding boxes touch or intersect.
This is all fine if the objects are square-ish or rectangular, but what if they're not? Remember the cat
from Chapters 2, 3, and 4? It heard about all the apples you were giving away and wanted to get in on
the action. Funny thing about this cat, though—it has terribly long ears.