GleamAnimation

From Gardenwiki

Jump to: navigation, search

A GleamAnimation is an easy way to temporarily change the color of an ImageSprite. This is useful if you want to draw attention to a certain part of the board. ZenBilging uses GleamAnimation to turn the combo yellow when a player makes a clear.

Here is the way ZenBilging uses GleamAnimation.

1. In the ZenBoardView class, import com.threerings.media.animation.GleamAnimation. You will likely also want to import java.awt.Color .

2. In the ZenBoardView class, the following method is added:

       /** make one bilge piece gleam */
   protected void gleamSpot(int row, int col, Color c) {
       GleamAnimation ga = new GleamAnimation(getSpriteManager(), 
               bilgeSprites[row][col], 
               c, 1000, 1000, true);
       addAnimation(ga);
   }   // end gleamSpot

3. The gleamSpot method is invoked where needed, giving the array coordinates of the ImageSprite and the color to be used. For example:

       gleamSpot(r, c, Color.YELLOW);

It is not necessary to add a method to handle the GleamAnimation. The parameters are a SpriteManager object, a Sprite object, a Color, the number of milliseconds to take to fade the color in, the number of milliseconds to take to fade the color out again, and a boolean. A boolean of true leaves the Sprite's image behind after fadeout. (More experimentation needs to be done to determine exactly what the boolean of false does.)

For more information on the parameters of the GleamAnimation, see GleamAnimation API.

Personal tools