Game Development Reference
In-Depth Information
Take a look at Figure 7-22 as the cat approaches the apple. The cat's ears are so long that they push
the edges of the bounding box well past something that defines the main part of the _]p object. Yet
depPaopK^fa_p, which uses these bounding boxes, regards it as a collision. The cat will get away scot
free with the apple, although it appears to be nowhere close to it. The pig and the owl would desper-
ately complain, and if you tried to get away with using this collision detection in a game, your players
would think something was seriously flawed—and they'd be right.
Figure 7-22. hitTestObject registers this as a collision. Even though the
objects are nowhere near one another, their bounding boxes intersect.
To be fair, this is not a problem with depPaopK^fa_p; its job is to check for collisions between the
bounding boxes of two objects. If it's not working for you, you need to decide whether you want to
modify the structure of your game and objects so that it starts working or find another way of doing
collision detection.
You'll be looking at a few other ways to do collision detection in this topic, but before you give up
hope on depPaopK^fa_p, let's look at some of the advantages it has over more-complex methods and
how you can make it work in your games.
Two great things about depPaopK^fa_p make it the favored first choice for doing collision detection:
it is easy to implement and puts very little strain on the CPU or Flash Player. In game design, in which
performance considerations can dictate many design decisions, this last reason alone is enough to
spur you on to see how much mileage you can wring out of the humble depPaopK^fa_p.
So, here goes. How can you use depPaopK^fa_p and still make it work reasonably well for irregularly
shaped objects?
Let's take a look at a few solutions.
 
Search Nedrilad ::




Custom Search