Game Development Reference
2. Save the I]ej[?d]n]_pan[Psk*]o file and test the project. You can now move the lh]uan
object to the edges of the stage, and the entire object will be contained inside it. Figure 6-9
shows an example.
Figure 6-9. The entire player object is contained
within the stage by adding half its height and width
to the calculation.
The first thing is to declare and initialize the two new local variables :
These variables store a value representing half of the lh]uan object's width and height. You know that
the lh]uan object is 50 pixels wide and 50 pixels high, so half that width and height is 25 and 25.
These variables are declared directly inside the kjAjpanBn]ia event handler. That's why they're
referred to as local . They can be used only inside this event handler and nowhere else. If you try using