Game Development Reference
In-Depth Information
Easing—advanced
In the previous examples, the lh]uan object moved by speeding up really quickly and then gradually
coming to a stop. This is a nice effect and is probably the most common easing effect you'll use in
your games, but what if you need something a little more complex? Wouldn't it be nice if the object
could gradually speed up when it starts moving and then gradually come to a stop as it approaches
its destination?
Easing effects like that can be achieved very easily using the AS3.0 Psaaj class. The Psaaj class allows
you to create a special “tween object” that will animate an object based on specific information that
you supply.
Let's take a look at a very simple example of the Psaaj class at work. In this chapter's source files, you'll
find a folder called >]oe_Psaaj. Open it as a project and test it. It features Button Fairy's arch-nemesis:
Bucket Robot. You'll see the robot at the left side of the stage gradually speed up, reach a maximum
speed, and then slowly come to a stop at the right side of the stage. The nk^kp object is using the
Nacqh]n*a]oaEjKqp method from the a]oejc package. Figure 10-9 illustrates what you'll see.
speeds up...
... reaches peak speed...
... slows down
Figure 10-9. The robot object gradually speeds up and slows down using the the Regular.easeInOut method of
the Tween class.
The code that makes this work is in the I]ej[>]oe_Psaaj*]o file:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*Arajp7
++Eilknp_h]ooao]j`l]_g]caonamqena`bknPsaajejc
eilknpbh*pn]joepekjo*Psaaj7
eilknpbh*pn]joepekjo*a]oejc*&7
 
Search Nedrilad ::




Custom Search