Pass the starting time for the animation in the constructor to allow

application code to make sure all animations are in sync, and to avoid
repeated calls to System.currentTimeMillis().


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@854 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2002-01-15 02:20:02 +00:00
parent 4e3d7d9ece
commit c25c66493e
@@ -1,5 +1,5 @@
// //
// $Id: ExplodeAnimation.java,v 1.2 2002/01/11 19:37:49 shaper Exp $ // $Id: ExplodeAnimation.java,v 1.3 2002/01/15 02:20:02 shaper Exp $
package com.threerings.media.animation; package com.threerings.media.animation;
@@ -20,6 +20,7 @@ public class ExplodeAnimation extends Animation
/** /**
* Constructs an explode animation. * Constructs an explode animation.
* *
* @param timestamp the animation starting time.
* @param bounds the bounds within which to animate. * @param bounds the bounds within which to animate.
* @param image the image to animate. * @param image the image to animate.
* @param xchunk the number of image chunks on the x-axis. * @param xchunk the number of image chunks on the x-axis.
@@ -30,12 +31,13 @@ public class ExplodeAnimation extends Animation
* @param rvel the chunk rotation velocity in rotations per millisecond. * @param rvel the chunk rotation velocity in rotations per millisecond.
*/ */
public ExplodeAnimation ( public ExplodeAnimation (
Rectangle bounds, Image image, int xchunk, int ychunk, long timestamp, Rectangle bounds, Image image, int xchunk, int ychunk,
int sx, int sy, float vel, float rvel) int sx, int sy, float vel, float rvel)
{ {
super(bounds); super(bounds);
// save things off // save things off
_start = timestamp;
_image = image; _image = image;
_xchunk = xchunk; _xchunk = xchunk;
_ychunk = ychunk; _ychunk = ychunk;
@@ -47,9 +49,6 @@ public class ExplodeAnimation extends Animation
_chunkcount = (_xchunk * _ychunk); _chunkcount = (_xchunk * _ychunk);
_cpos = new int[_chunkcount]; _cpos = new int[_chunkcount];
// save the animation starting time
_start = System.currentTimeMillis();
// determine chunk dimensions // determine chunk dimensions
_cwid = image.getWidth(null) / _xchunk; _cwid = image.getWidth(null) / _xchunk;
_chei = image.getHeight(null) / _ychunk; _chei = image.getHeight(null) / _ychunk;
@@ -57,9 +56,6 @@ public class ExplodeAnimation extends Animation
_hchei = _chei / 2; _hchei = _chei / 2;
// initialize the chunk positions // initialize the chunk positions
int cx = sx + (image.getWidth(null) / 2);
int cy = sy + (image.getHeight(null) / 2);
int cpos = (cx << 16 | cy);
for (int ii = 0; ii < _chunkcount; ii++) { for (int ii = 0; ii < _chunkcount; ii++) {
int xpos = ii % _xchunk; int xpos = ii % _xchunk;
int ypos = ii / _xchunk; int ypos = ii / _xchunk;