Game Development Reference
In-Depth Information
++AjaiuPsk
eb$ajaiuPsk9jqhh%
w
eb$ajaiuPsk*depPaopLkejp$^qhhap*t(^qhhap*u(pnqa%%
w
ajaiuPsk*oq^K^fa_p*iapan*se`pd)9-,7
eb$ajaiuPsk*oq^K^fa_p*iapan*se`pd8-%
w
ajaiuPsk*oq^K^fa_p*opkl$%7
naikra?deh`$ajaiuPsk%7
ajaiuPsk9jqhh7
y
naikra?deh`$^qhhap%7
^qhhap9jqhh7
y
y
y
This method is called every time a new bullet is created, which is every time the player presses the
spacebar. It's lq^he_ so that outside classes such as >qhhap can access it. The actual instance names
of the bullets will be different, but that doesn't matter because the method refers to them all as
^qhhap. The great thing about this system is that it all happens without you needing to know the actual
instance names of the bullets themselves. You could have one bullet or 1000, and the code remains
the same.
The collision-detection code is very straightforward. When the bullets hit the enemies, they're removed
from the stage, and the width of the enemies' health meters are reduced by ten pixels. If the width of
the meters becomes less than one pixel, the enemies are removed from the stage.
After the enemy and bullet objects are removed from the stage, the references to them are also
assigned a jqhh value, like this:
ajaiuKja9jqhh7
ajaiuPsk9jqhh7
^qhhap9jqhh7
Assigning a jqhh value to variables that reference objects ensures that Flash will remove the object
from the Flash Player's memory.
As it did before, the code needs to first check whether ajaiuKja and ajaiuPsk actually exist on the
stage by using this check:
eb$ajaiuPsk9jqhh%
The code generates errors if the enemy has already been removed and the code can't find it.
 
Search Nedrilad ::




Custom Search