Game Development Reference
In-Depth Information
When All Else Fails, Mix 'N Match
Sometimes, any one approach to collision detection is not enough
to get the job done, effectively. That
s when a combination of
approaches can work, depending on the scenario. For instance, in
the earlier example, we saw how the distance detection method
served well to determine collisions between the two players.
However, that method doesn
'
t work well to determine the overlap
of the player Sprites on screen. In addition to using distance for
interaction, we can do a basic hitTestObject test to determine when
they are overlapping and to adjust their indices in the display list.
In that perspective skewed instance, when one player has a lower
y value, it should appear behind the other player.
The most important thing to keep in mind when applying colli-
sion detection techniques is to keep an open mind to different
options. Like in the case of physics simulation, pixel-perfect
precision is rarely necessary and will end up costing you too much
in performance. It is a balance of accuracy, speed, and flexibility
that ultimately yields the best detection. We
'
ll look at more practi-
cal examples of collision detection in Chapters 14
'
-
16.
Search Nedrilad ::




Custom Search