com.threerings.media.animation
Class ExplodeAnimation

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.animation.Animation
          extended by com.threerings.media.animation.ExplodeAnimation
All Implemented Interfaces:
Shape

public class ExplodeAnimation
extends Animation

An animation that displays an object exploding into chunks, fading out as they fly apart. The animation ends when all chunks have exited the animation bounds, or when the given delay time (if any is specified) has elapsed.


Nested Class Summary
static class ExplodeAnimation.ExplodeInfo
          A class that describes an explosion's attributes.
 
Nested classes/interfaces inherited from class com.threerings.media.animation.Animation
Animation.AnimCompletedOp, Animation.AnimStartedOp
 
Field Summary
protected  float _alpha
          The percent alpha with which to render the chunks.
protected  float _angle
          The current chunk rotation.
protected  int _chei
          The individual chunk dimensions in pixels.
protected  int _chunkcount
          The total number of image chunks.
protected  Color _color
          The color to render the object chunks in if we're using a color.
protected  int _cwid
          The individual chunk dimensions in pixels.
protected  int[] _cxpos
          The current x-axis position of each chunk.
protected  int[] _cypos
          The current y-axis position of each chunk.
protected  long _end
          The ending animation time.
protected  int _hchei
          The individual chunk dimensions in pixels, halved for handy use in repeated calculations.
protected  int _hcwid
          The individual chunk dimensions in pixels, halved for handy use in repeated calculations.
protected  Mirage _image
          The image to animate if we're using an image.
protected  ExplodeAnimation.ExplodeInfo _info
          The explode info.
protected  int _ohei
          The exploding object position and dimensions.
protected  int _owid
          The exploding object position and dimensions.
protected  int _ox
          The exploding object position and dimensions.
protected  int _oy
          The exploding object position and dimensions.
protected  long _start
          The starting animation time.
protected  float[] _sxvel
          The starting x-axis velocity of each chunk.
protected  float[] _syvel
          The starting y-axis velocity of each chunk.
protected  Rectangle _wrect
          A reusable working rectangle.
 
Fields inherited from class com.threerings.media.animation.Animation
_finished
 
Fields inherited from class com.threerings.media.AbstractMedia
_bounds, _firstTick, _mgr, _observers, _renderOrder, HUD_LAYER
 
Constructor Summary
ExplodeAnimation(Color color, ExplodeAnimation.ExplodeInfo info, int x, int y, int width, int height)
          Constructs an explode animation with the chunks represented as filled rectangles of the specified color.
ExplodeAnimation(Mirage image, ExplodeAnimation.ExplodeInfo info, int x, int y, int width, int height)
          Constructs an explode animation with the chunks represented as portions of the actual image.
 
Method Summary
 void fastForward(long timeDelta)
          Called when the appropriate media manager has been paused for some length of time and is then unpaused.
protected  void init(ExplodeAnimation.ExplodeInfo info, int x, int y, int width, int height)
          Initializes the animation with the attributes of the given explode info object.
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 void tick(long timestamp)
          Called periodically by this media's manager to give it a chance to do its thing.
protected  void toString(StringBuilder buf)
          This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific information to the string buffer.
 
Methods inherited from class com.threerings.media.animation.Animation
addAnimationObserver, didFinish, isFinished, removeAnimationObserver, reset, setLocation, willFinish, willStart
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, shutdown, toString, viewLocationDidChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_angle

protected float _angle
The current chunk rotation.


_sxvel

protected float[] _sxvel
The starting x-axis velocity of each chunk.


_syvel

protected float[] _syvel
The starting y-axis velocity of each chunk.


_cxpos

protected int[] _cxpos
The current x-axis position of each chunk.


_cypos

protected int[] _cypos
The current y-axis position of each chunk.


_cwid

protected int _cwid
The individual chunk dimensions in pixels.


_chei

protected int _chei
The individual chunk dimensions in pixels.


_hcwid

protected int _hcwid
The individual chunk dimensions in pixels, halved for handy use in repeated calculations.


_hchei

protected int _hchei
The individual chunk dimensions in pixels, halved for handy use in repeated calculations.


_chunkcount

protected int _chunkcount
The total number of image chunks.


_info

protected ExplodeAnimation.ExplodeInfo _info
The explode info.


_ox

protected int _ox
The exploding object position and dimensions.


_oy

protected int _oy
The exploding object position and dimensions.


_owid

protected int _owid
The exploding object position and dimensions.


_ohei

protected int _ohei
The exploding object position and dimensions.


_color

protected Color _color
The color to render the object chunks in if we're using a color.


_image

protected Mirage _image
The image to animate if we're using an image.


_start

protected long _start
The starting animation time.


_end

protected long _end
The ending animation time.


_alpha

protected float _alpha
The percent alpha with which to render the chunks.


_wrect

protected Rectangle _wrect
A reusable working rectangle.

Constructor Detail

ExplodeAnimation

public ExplodeAnimation(Color color,
                        ExplodeAnimation.ExplodeInfo info,
                        int x,
                        int y,
                        int width,
                        int height)
Constructs an explode animation with the chunks represented as filled rectangles of the specified color.

Parameters:
color - the color to render the chunks in.
info - the explode info object.
x - the x-position of the object.
y - the y-position of the object.
width - the width of the object.
height - the height of the object.

ExplodeAnimation

public ExplodeAnimation(Mirage image,
                        ExplodeAnimation.ExplodeInfo info,
                        int x,
                        int y,
                        int width,
                        int height)
Constructs an explode animation with the chunks represented as portions of the actual image.

Parameters:
image - the image to animate.
info - the explode info object.
x - the x-position of the object.
y - the y-position of the object.
width - the width of the object.
height - the height of the object.
Method Detail

init

protected void init(ExplodeAnimation.ExplodeInfo info,
                    int x,
                    int y,
                    int width,
                    int height)
Initializes the animation with the attributes of the given explode info object.


fastForward

public void fastForward(long timeDelta)
Description copied from class: AbstractMedia
Called when the appropriate media manager has been paused for some length of time and is then unpaused. Media should adjust any time stamps that are maintained internally forward by the delta so that time maintains the illusion of flowing smoothly forward.

Overrides:
fastForward in class AbstractMedia

tick

public void tick(long timestamp)
Description copied from class: AbstractMedia
Called periodically by this media's manager to give it a chance to do its thing.

Specified by:
tick in class AbstractMedia
Parameters:
timestamp - a time stamp associated with this tick. Note: this is not obtained from a call to System.currentTimeMillis() and cannot be compared to timestamps obtained there from.

paint

public void paint(Graphics2D gfx)
Description copied from class: AbstractMedia
Called by the appropriate manager to request that the media render itself with the given graphics context. The media may wish to inspect the clipping region that has been set on the graphics context to render itself more efficiently. This method will only be called after it has been established that this media's bounds intersect the clipping region.

Specified by:
paint in class AbstractMedia

toString

protected void toString(StringBuilder buf)
Description copied from class: AbstractMedia
This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific information to the string buffer.

Overrides:
toString in class AbstractMedia