From 6029530e732e010c6bfb668d8ea55cd884cea427 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Thu, 24 Apr 2008 01:05:10 +0000 Subject: [PATCH] Wait till willStart to create the gleaming functions so subclasses can fill in their desired alpha ranges and so on and the huge constructors aren't needed git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@476 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../media/animation/GleamAnimation.java | 52 +++---------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/src/java/com/threerings/media/animation/GleamAnimation.java b/src/java/com/threerings/media/animation/GleamAnimation.java index 7ad477f0..c0fcc394 100644 --- a/src/java/com/threerings/media/animation/GleamAnimation.java +++ b/src/java/com/threerings/media/animation/GleamAnimation.java @@ -49,10 +49,10 @@ public class GleamAnimation extends Animation * @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color * and the gleam color will fade out, leaving just the sprite imagery. */ - public GleamAnimation (Sprite sprite, Color color, int upmillis, - int downmillis, boolean fadeIn) + public GleamAnimation (Sprite sprite, Color color, int upmillis, int downmillis, + boolean fadeIn) { - this(null, sprite, color, upmillis, downmillis, fadeIn, 750, 0); + this(null, sprite, color, upmillis, downmillis, fadeIn); } /** @@ -65,41 +65,6 @@ public class GleamAnimation extends Animation */ public GleamAnimation (SpriteManager spmgr, Sprite sprite, Color color, int upmillis, int downmillis, boolean fadeIn) - { - this(spmgr, sprite, color, upmillis, downmillis, fadeIn, 750, 0); - } - - /** - * Creates a gleam animation with the supplied sprite. The sprite will be faded to the - * specified color and then back again. The sprite may be already added to the supplied sprite - * manager or not, but when the animation is complete, it will have been added. - * - * @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color - * and the gleam color will fade out, leaving just the sprite imagery. - * @param maxAlpha the maximum alpha value to scale the color to. - * @param millisBetweenUpdates milliseconds to wait between actually updating the alpha and - * redrawing - */ - public GleamAnimation (SpriteManager spmgr, Sprite sprite, Color color, int upmillis, - int downmillis, boolean fadeIn, int maxAlpha, int millisBetweenUpdates) - { - this(spmgr, sprite, color, upmillis, downmillis, fadeIn, 750, 0, 0); - } - - /** - * Creates a gleam animation with the supplied sprite. The sprite will be faded to the - * specified color and then back again. The sprite may be already added to the supplied sprite - * manager or not, but when the animation is complete, it will have been added. - * - * @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color - * and the gleam color will fade out, leaving just the sprite imagery. - * @param maxAlpha the maximum alpha value to scale the color to. - * @param millisBetweenUpdates milliseconds to wait between actually updating the alpha and - * redrawing - * @param minAlpha the minimum alpha value to scale the color to. - */ - public GleamAnimation (SpriteManager spmgr, Sprite sprite, Color color, int upmillis, - int downmillis, boolean fadeIn, int maxAlpha, int millisBetweenUpdates, int minAlpha) { super(new Rectangle(sprite.getBounds())); _spmgr = spmgr; @@ -107,13 +72,9 @@ public class GleamAnimation extends Animation _color = color; _upmillis = upmillis; _downmillis = downmillis; - _maxAlpha = maxAlpha; - _upfunc = new LinearTimeFunction(_minAlpha, _maxAlpha, upmillis); - _downfunc = new LinearTimeFunction(_maxAlpha, _minAlpha, downmillis); _fadeIn = fadeIn; - _millisBetweenUpdates = millisBetweenUpdates; } - + @Override // documentation inherited public void tick (long timestamp) { @@ -209,6 +170,9 @@ public class GleamAnimation extends Animation @Override // documentation inherited protected void willStart (long tickStamp) { + _upfunc = new LinearTimeFunction(_minAlpha, _maxAlpha, _upmillis); + _downfunc = new LinearTimeFunction(_maxAlpha, _minAlpha, _downmillis); + super.willStart(tickStamp); // remove the sprite we're fiddling with from the manager; we'll @@ -237,7 +201,7 @@ public class GleamAnimation extends Animation protected TimeFunction _downfunc; protected int _upmillis; protected int _downmillis; - protected int _maxAlpha; + protected int _maxAlpha = 750; protected int _minAlpha; protected int _alpha = -1; protected long _lastUpdate;