Game Development Reference
In-Depth Information
But if you are a code junkie, read on! Flip back a few pages to Figure 7-36 and try to become familiar
with the problem you need to solve. If you understand the problem and the logic used to solve it, all
the new code does is to turn that logic into AS3.0 code. In fact, the problem you face is exactly the
same as the problem you faced in Chapter 6 when you were figuring out screen boundaries. The only
difference is that the calculations that you need to make to figure out how far these boundaries have
been breached are a little more complex.
Let's walk the through the ?khheoekj class and have a look at what's new and how it works:
1. Double-click the Collision.as file in the Project panel to open it.
2. You'll notice quite a lot of code there that you won't understand (you'll look at most of it in
later chapters). All you're interested in now is the ^hk_g function definition, which is the first
function definition in the class. Here's what the ?khheoekj class and the ^hk_g function defini-
tion look like:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*caki*Lkejp7
lq^he__h]oo?khheoekj
w
lq^he_bqj_pekj?khheoekj$%
w
y
op]pe_lq^he_bqj_pekj^hk_g$k^fa_p=6Ikrea?hel( ±
k^fa_p>6Ikrea?hel%6rke`
w
r]nk^fa_p=[D]hbse`pd6Jqi^an9k^fa_p=*se`pd+.7
r]nk^fa_p=[D]hbdaecdp6Jqi^an9k^fa_p=*daecdp+.7
r]nk^fa_p>[D]hbse`pd6Jqi^an9k^fa_p>*se`pd+.7
r]nk^fa_p>[D]hbdaecdp6Jqi^an9k^fa_p>*daecdp+.7
r]n`t6Jqi^an9k^fa_p>*t)k^fa_p=*t7
r]nkt6Jqi^an9k^fa_p>[D]hbse`pd' ±
k^fa_p=[D]hbse`pd)I]pd*]^o$`t%7
eb$kt:,%
w
r]n`u6Jqi^an9k^fa_p=*u)k^fa_p>*u7
r]nku6Jqi^an9k^fa_p>[D]hbdaecdp' ±
k^fa_p=[D]hbdaecdp)I]pd*]^o$`u%7
eb$ku:,%
w
eb$kt8ku%
w
eb$`t8,%
w
++?khheoekjkjNecdp
ku9,7
y
 
Search Nedrilad ::




Custom Search