Game Development Reference
In-Depth Information
o_kna''7
iaoo]ca@eolh]u*patp9Opnejc\$o_kna%7
_khheoekjD]oK__qnna`9pnqa7
y
y
ahoa
w
ajaiu*ckpk=j`Opkl\$-%7
_khheoekjD]oK__qnna`9b]hoa7
y
++?da_gbknaj`kbc]ia
eb\$da]hpd*iapan*se`pd8-%
w
iaoo]ca@eolh]u*patp9C]iaKran7
y
eb\$o_kna:91%
w
iaoo]ca@eolh]u*patp9Ukqskj7
y
++depPaopLkejpat]ilha
eb\$dehh*depPaopLkejp\$lh]uan*t(lh]uan*u(pnqa%%
w
y
ahoa
w
y
y
8. Save the I]ej[Lh]ucnkqj`*]o file and test the project. The
dynamic text field tells you whether the player is on or off
the hill. But look closely. Can you tell at which point the
program detects that the player is on the hill? It's actu-
ally using the absolute middle point of the lh]uan object.
When the center point of the lh]uan object is touching any
part of the surface area of the dehh object, the collision is
detected. Figure 7-28 illustrates this a little more clearly.
This is pretty amazing. Absolutely precise collision detection
without bounding boxes! Just like depPaopK^fa_p, you attach
depPaopLkejp to any object that you want to check for a collision
using dot notation. That first object is the one whose shape you
want to use in the collision. You used dehh in the previous code:
eb\$dehh*depPaopLkejp\$lh]uan*t(lh]uan*u(pnqa%%
Figure 7-28. Use hitTestPoint to check
whether a single point in an object is touch-
ing the actual shape of another object.