Game Development Reference
In-Depth Information
How does the object get a jqhh value? It's given one when it's removed from the game by being hit by
a bullet in the _da_g?khheoekjSepdAjaieao method:
naikra?deh`$ajaiuKja%7
ajaiuKja9jqhh7
You'll see how this works ahead. There's also a lot more information on removing objects at the end
of the chapter in the section called “Removing objects from the game.”
Losing the game
When the health meter reaches zero, the Game Over screen is displayed with this message: Game Over,
You Lost!
eb$da]hpd*iapan*se`pd8-%
w
r]nc]iaKranHkop6C]iaKran9jasC]iaKran$%7
c]iaKranHkop*iaoo]ca@eolh]u*patp9C]iaKran'Xj'UkqHkop7
l]najp*]``?deh`$c]iaKranHkop%7
l]najp*naikra?deh`$pdeo%7
y
The code creates the c]iaKranHkop object, which is an instance of the C]iaKran symbol.
r]nc]iaKranHkop6C]iaKran9jasC]iaKran$%7
The C]iaKran symbol contains a dynamic text field called iaoo]ca@eolh]u, which is used to display
the message:
c]iaKranHkop*iaoo]ca@eolh]u*patp9C]iaKran'Xj'UkqHkop7
Next, the c]iaKranHkop object is displayed on the stage:
l]najp*]``?deh`$c]iaKranHkop%7
I want the Game Over screen to be added directly to the main stage. l]najp refers to the main stage,
so I can use the l]najp keyword to add the Game Over screen to the main stage. Figure 8-22 illustrates
what the code does.
Finally, `qjcakjKja itself is removed:
l]najp*naikra?deh`$pdeo%7
l]najp again refers to the stage, and pdeo refers to this object , which is `qjcakjKja. Why is the l]najp
property asked to remove the object?
AS3.0 doesn't permit objects to add or remove themselves. Only an object's container can remove it.
This is logical because think how awkward it would be in a real-life situation if your socks removed
themselves from your sock drawer instead of removing them yourself?
 
Search Nedrilad ::




Custom Search