Share this Page URL

Chapter 5. Collision Detection > Detection Using hitTest() - Pg. 62

Collision Detection 62 In this chapter we'll cover several of the most common types of collision detection, including those having to do with intersections or collisions of lines with lines, circles with lines, and rectangles with other rectangles. As I mentioned earlier, there are two main types of programmatic collision detection used in Flash: the use of the hitTest() method of the MovieClip object, and the use of math to determine if a collision has occurred. As you will see from what follows in this chapter, hitTest() has its uses but is vastly inferior to collision-detection scripts that use math. By using math to determine collisions, not only can you determine if a collision is happening, but in some cases you can also tell if a collision is about to happen, and at precisely which position this collision will occur. We need this level of precision for some of the more advanced types of games, such as pinball or billiards.