Game Development Reference
In-Depth Information
You'll initialize it to b]hoa when the program starts and then set it to pnqa when a collision takes place.
That should work. Try it out!
1. Add the code in bold to the I]ej class definition and ejep method:
lq^he__h]ooI]ej[Lh]ucnkqj`atpaj`oIkrea?hel
w
r]nrt6ejp7
r]nru6ejp7
r]no_kna6qejp7
r]n_khheoekjD]oK__qnna`6>kkha]j7
lq^he_bqj_pekjI]ej[Lh]ucnkqj`$%
w
ejep$%7
y
bqj_pekjejep$%6rke`
w
++ejepe]hevar]ne]^hao
rt9,7
ru9,7
o_kna9,7
_khheoekjD]oK__qnna`9b]hoa7
++ejepe]hevak^fa_po
ajaiu*opkl$%7
++=``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
2. Modify the kjAjpanBn]ia event handler so that it looks like the following (the new code makes
use of the jkp operator, which is an exclamation mark):
You haven't used the jkp operator before, so look for it in the code and be careful to add it—
it's easy to miss. I'll explain the use of the jkp operator in detail ahead.
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
ajaiu*ckpk=j`Opkl$.%7
da]hpd*iapan*se`pd))7
 
Search Nedrilad ::




Custom Search