Game Development Reference
In-Depth Information
The code contains three variables to store the new acceleration data, which are initialized by the con-
structor method:
[]__ahan]pekjT9,7
[]__ahan]pekjU9,7
[olaa`Heiep917
The []__ahan]pekjT and []__ahan]pekjU variables store the value that determines by how much
the object accelerates. Because you don't want the object to move when it first appears on the stage,
[]__ahan]pekjT and []__ahan]pekjU are initialized to zero. [olaa`Heiep is the maximum speed that
you want the object to travel. A value of 1 means that the object will travel a maximum of no more
than 5 pixels per frame.
Just below the variable initialization is a directive that reads pdeo*a]no*opkl$%7. The
?]p symbol contains an animated subobject called a]no, which you don't want to play
for now. You'll see this in action soon enough.
The work of assigning a value to the []__ahan]pekjT and []__ahan]pekjU variables is done by the
kjGau@ksj event handler:
lner]pabqj_pekjkjGau@ksj$arajp6Gau^k]n`Arajp%6rke`
w
eb$arajp*gau?k`a99Gau^k]n`*HABP%
w
[]__ahan]pekjT9),*.7
y
eb$arajp*gau?k`a99Gau^k]n`*NECDP%
w
[]__ahan]pekjT9,*.7
y
eb$arajp*gau?k`a99Gau^k]n`*QL%
w
[]__ahan]pekjU9),*.7
y
eb$arajp*gau?k`a99Gau^k]n`*@KSJ%
w
[]__ahan]pekjU9,*.7
y
y
If []__ahan]pekjT has a positive value, the object moves to the right. A negative value makes it move
left. A positive []__ahan]pekjU value makes the object move down, and a negative value makes it
move up.
 
Search Nedrilad ::




Custom Search