Game Development Reference
Picking up the key
You'll see how simple the code of the game really is when you break it up piece by piece. The player's
first task is to pick up the key. The @qjcakjKja[I]j]can class uses depPaopK^fa_p to check for this:
If the lh]uan object touches the key, the key becomes a child object of the lh]uan by using ]``?deh`,
which allows the lh]uan to carry it around.
To center the `kknGau object over the lh]uan, you have to set its t and u positions to ,. Because it's
now a child of the lh]uan, , refers to position , on the lh]uan object, not the stage. The Lh]uan sym-
bol's center t and u point is ,. The key's rotation is set to /,,, which is just a simple effect to highlight
that it's been picked up.
A very important thing that this code does is set the player's d]oGau setter to pnqa, which will be
needed when the player tries to open a door. Figure 8-17 illustrates how the setter is set.
lh]uan* d]oGau 9pnqa7
lq^he_bqj_pekjoap d]oGau $gauOp]pa6>kkha]j%
The player's _hasKey
property is set to true.
Figure 8-17. The DungeonOne_Manager class sets the player's _hasKey property to true using the Player class's