Game Development Reference
In-Depth Information
These are the files you'll be using as the start point.
The chapter's source files contain files called I]ej[Lh]ucnkqj`[., I]ej[Lh]ucnkqj`[/,
I]ej[Lh]ucnkqj`[0, and so on all the way up to I]ej[Lh]ucnkqj`[5. Each of these files
contains the completed code for every example that you'll be looking at. If you don't
feel like typing in the code manually, you can change the ejpan]_peraLh]ucnkqj`*bh]
document class to match the name of one of these files. The effect will be the same as if
you had typed in the code.
What makes most computer games fun to play is that they are, in their essence, a simplified simula-
tion of the real world. Like the real world, they contain objects that you can interact with in some
way. These objects might be walls that block your movement, friends who help you, or enemies who
harm you.
To create these sorts of interactive objects, you first need a way of finding out whether one object is
touching another object. In computer game programming, this is called collision detection . Collision
detection is just game programming jargon for “what happens when things bump into one another.”
AS3.0 has a very simple way of detecting collisions between objects: the depPaopK^fa_p method.
Using hitTestObject
The depPaopK^fa_p method can be used to check whether any two objects have bumped into one
another. Let's say that you have a Movie Clip object called _]n that the player can control. You also
have a Movie Clip object called s]hh. In your game, if the player's car hits the wall, it should crash.
In plain English, you would want to write some computer code that looks something like this:
Search Nedrilad ::

Custom Search