Game Development Reference
In-Depth Information
Weapon Class
lner]pabqj_pekjkjGau@ksj$arajp6Gau^k]n`Arajp%6rke`
w
eb$arajp*gau?k`a99Gau^k]n`*OL=?A%
w
odkkp>qhhap$%7
y
y
***
lner]pabqj_pekjodkkp>qhhap$%6rke`
w
eb$[sa]lkj=nia`%
w
l]najp*]``?deh`$jas>qhhap$%%7
y
y
Figure 8-23. Press the spacebar to trigger the shootBullet method and add a bullet to the stage.
You'll see how the bullets actually work next.
Using bullet objects
All the bullet objects use the >qhhap class—it positions the bullets on the stage and makes them
move. It also sends references of the bullet objects back to the @qjcakjKja[I]j]can class so they can
be checked for collisions with enemies.
It's important to remember that a new instance of this class is created every time a bullet is added to
the stage . This one class is shared by countless bullet instances:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*Arajp7
lq^he__h]oo>qhhapatpaj`oIkrea?hel
w
lner]par]n[rt6ejp7
lner]par]n[ru6ejp7
lq^he_bqj_pekj>qhhap$%
w
]``ArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
y
lner]pabqj_pekjkj=``a`PkOp]ca$arajp6Arajp%6rke`
w
++Pda^qhhap#orahk_epu
 
Search Nedrilad ::




Custom Search