ScaleAnimation

A ScaleAnimation is an easy way to have an image change from one size to another. Parfait uses ScaleAnimation with the non-permanent booches.

Here is how to use ScaleAnimation in a BoardView class.

Import com.threerings.media.animation.ScaleAnimation and com.threerings.media.animation.AnimationObserver.

Add lines similar to:

ScaleAnimation ea = new ScaleAnimation( ... various parameters... ); ea.addAnimationObserver(this); ea.setRenderOrder(2); addAnimation(ea);

The setRenderOrder(2) makes the image show in front of those images with lower render orders.

The parameters for a ScaleAnimation constructor are:

ScaleAnimation(Mirage image,                     Point center,                      float startScale,                      float endScale,                      int duration)

The image is the image to be painted. The Point center gives the screen coordinates of the pixel where the center of the image will be. The startScale is the amount to scale the image at time zero; that is, 1f for full size, 0f for not showing, .5 for half size, etc. The endScale is similar: how big do we want the image at the end of the animation? The duration is the number of milliseconds to take for the animation, smoothly going from the startScale size to the endScale size. In Parfait, the booch animation uses these lines to create the ScaleAnimation named ea at the point (locX, locY):

Point pt = new Point(locX, locY); ScaleAnimation ea = new ScaleAnimation(_images[48],               pt, 1f, 0f, 2000);

This makes an animation that lasts two seconds, starting with a full sized booch image that shrinks to nothing. For more information on the ScaleAnimation, see ScaleAnimation API.