Game Development Reference
In-Depth Information
11. Open the FLA's properties by clicking anywhere on the main stage (except on the lh]uan object).
In the Properties panel, change the FPS value to 30 . Figure 6-6 shows what this looks like.
Figure 6-6. Change the movie's fps to 30 for smoother
animation.
12. Save the _d]n]_pan?kjpnkh*bh] file.
13. Test the project. Use the arrow keys to move the lh]uan object around the stage. The move-
ment is now very smooth, and you can also move the character across the stage diagonally. Just
the kind of character control you're looking for!
When you test the movie, you might see two warnings in the Output panel that read
something like this: Warning 1090: Migration issue . Earlier versions of ActionScript had
two methods, called kjGauQl and kjGau@ksj , which were built directly into the lan-
guage. They were dropped from AS3.0 when the language was overhauled, but they
are exactly the same method names that you used for the methods in the program.
The warnings tell you that if you want to use these methods, you need to create an
event handler for them because Flash will no longer do it for you. That's exactly what
you've done, so you can safely ignore these warnings. (If you don't want these sorts of
warnings displayed in future, you can switch them off in the Warnings section of Flash's
Preferences .)
Let's take a look at how this new program differs from the first one you wrote.
Moving with velocity
The first thing to notice are the two new integer variables, rt and ru, which store the lh]uan object's
speed—how fast it's going. Actually, I need to be a little more accurate here. It's not really the speed
of the object that you're storing, but the velocity . That's what the v stands for in the variable names:
velocity x and velocity y .
Velocity is speed, but it's also direction. This is sometimes a confusing thing for beginners to grasp, so
it's worth discussing in more detail. Have a look at this directive:
rt9)17
rt refers to the velocity on the x (horizontal) axis. This actually tells you two things. First, 5 is the number
of pixels that you want the lh]uan object to move each frame. You set the frame rate to 30 fps, which
means that the object will move 5 pixels each frame, or 150 pixels each second. So that's the first thing:
its speed.
 
Search Nedrilad ::




Custom Search