12

DON’T HIT ME: COLLISION DETECTION TECHNIQUES

CHAPTER OUTLINE

What You Can Do versus What You Need

HitTestObject—The Most Basic Detection

HitTestPoint—One Step Up

Radius/Distance Testing—Great for Circles

Rect Testing

The Enemy Class

The SimpleShooterCollisions Class Additions

Weaknesses of This Method

Pixel-Perfect Collision Detectionand Physics

When All Else Fails, Mix ‘N Match

If you do much game development, you’ll eventually need to determine when two objects on screen are colliding with one another. Although Flash does not automatically notify you of this, there are a number of different methods that can be used to detect it. In this chapter, we’ll look at several types of collision detection and in which scenarios they work best. We’ll ...

Get Real-World Flash Game Development, 2nd 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.