Game Development Reference
Applying gravity to the object is simply a matter of adding it to the [ru value, which this directive
That's it! That's all you need to do to implement gravity.
The Lh]uan[Cn]repu class goes a little bit further, however. You want to allow the player to make the
cat move up when the up arrow is pressed. There is actually more than one way to do this, and this
class represents the slightly more complex way.
The way this works is that when the player presses the up arrow key, [cn]repu is set to , in the
kjGau@ksj event handler:
This allows the _]p object to move up the stage freely and also triggers its a]no subobject to start its
animation. The ears are animated using a simple motion tween. Have a look at the A]no symbol in the
Library to take a closer look at how this works. (Notice that there's also no code for the down arrow
key. You don't need it—gravity takes care of moving the object down.)
When the keys are released, the [cn]repu variable is set back to its original value of ,*/.
The ears are also stopped and returned to their starting frame. You can create this same effect by
just giving __ahan]pekjU a positive value when you need gravity applied. (A positive u value pulls
the object to the bottom of the stage.) It means that you could dispense with having to create the
[cn]repu variable altogether, and the class would contain a bit less code. However, the nice thing