Game Development Reference
7. Add the following code in bold to the kjAjpanBn]ia method:
8. Save the I]ej[Lh]ucnkqj`*]o file and test the project. Now when the
lh]uan object collides with the ajaiu object, you might see some-
thing like Figure 7-7. The owl ruffles its feathers and looks perturbed.
Oh, what a pesky little pig! Maybe you can find some way for the owl to get
him back in the next section. (The I]ej[Lh]ucnkqj`[/*]o file contains the
completed code for this section.)
Figure 7-7. The enemy object
stops at frame 2 when it collides
with the player object.
Reducing a health meter
Many games use a health meter to determine when the game is over. When the player bumps into
bad things such as enemies, the health meter gradually shrinks in size. When the health meter disap-
pears, the game ends.
Implementing a health meter is very easy. It makes clever use of the Movie Clip class's se`pd property.
Let's create a health meter for the lh]uan object.
1. Create a new Movie Clip symbol called Da]hpd.
2. The Da]hpd symbol's editing window will open.