Collisions are an inevitable fact of life in an animated world. So far, the movies we created do not know how to detect when two objects have collided or what to do when they do. This section focuses on the first issue: collision detection. Responding properly to collisions will be treated in detail in Chapter 11.
In general, collision detection can be a tricky problem, but if the objects to be tested are rectangular in shape, there is a very simple built-in method:
Using the hitTestObject() method
hitTestObject() method determines whether two display objects (such as sprites or movie clips) are in collision:
The outcome is a
Boolean: it returns
true if they do and