Game Development Reference
In-Depth Information
Moving an object with easing
It's likely that in a game scenario you will want your player character to move with a little more grace
than simply staying fixed to the mouse position exactly. Using the simple easing formula discussed
earlier, you can create some very elegant systems to move objects.
In this chapter's source files, you'll find a folder called A]oejcSepdIkqoa. Open it as a project and
test it. If you click anywhere on the stage, Button Fairy serenely flutters to that spot, gradually easing
into position (see Figure 10-8).
Figure 10-8. Click anywhere on the stage, and
Button Fairy eases to that position.
When Button Fairy has reached her destination point, you'll see the words Player reached target dis-
played in the Output panel.
Here's the code that makes this happen:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*Arajp7
eilknpbh]od*arajpo*IkqoaArajp7
lq^he__h]ooI]ej[A]oejcSepdIkqoaatpaj`oIkrea?hel
w
++@a_h]na_kjop]jpo
lner]pa_kjopA=OEJC6Jqi^an9,*-7
++@a_h]nar]ne]^hao
lner]par]n[p]ncapT6Jqi^an7
lner]par]n[p]ncapU6Jqi^an7
 
Search Nedrilad ::




Custom Search