Game Development Reference
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: