Game Development Reference
In-Depth Information
++=``arajpheopajano
op]ca*]``ArajpHeopajan$Gau^k]n`Arajp*GAU[@KSJ(kjGau@ksj%7
op]ca*]``ArajpHeopajan$Gau^k]n`Arajp*GAU[QL(kjGauQl%7
]``ArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
y
7. Add the following code in bold to the kjAjpanBn]ia method:
bqj_pekjkjAjpanBn]ia$arajp6Arajp%6rke`
w
++Ikrapdalh]uan
lh]uan*t'9rt7
lh]uan*u'9ru7
++?khheoekj`apa_pekj
eb$lh]uan*depPaopK^fa_p$ajaiu%%
w
iaoo]ca@eolh]u*patp9Kq_d7
ajaiu*ckpk=j`Opkl$.%7
y
ahoa
w
iaoo]ca@eolh]u*patp9Jk_khheoekj***7
ajaiu*ckpk=j`Opkl$-%7
y
y
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.
 
Search Nedrilad ::




Custom Search