com.threerings.media.animation
Class SpriteAnimation

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

public class SpriteAnimation
extends Animation
implements PathObserver


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.animation.Animation
Animation.AnimCompletedOp, Animation.AnimStartedOp
 
Field Summary
protected  Path _path
          The path along which we'll move our sprite.
protected  Sprite _sprite
          The sprite associated with this animation.
protected  SpriteManager _spritemgr
          The sprite manager managing our sprite.
 
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
SpriteAnimation(SpriteManager spritemgr, Sprite sprite, Path path)
          Constructs a sprite animation for the given sprite.
 
Method Summary
protected  void didFinish(long tickStamp)
          Called when the animation is finished and the animation manager has removed it from service.
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 void pathCancelled(Sprite sprite, Path path)
          Called when a sprite's path is cancelled either because a new path was started or the path was explicitly cancelled with Sprite.cancelMove().
 void pathCompleted(Sprite sprite, Path path, long when)
          Called when a sprite completes its traversal of a path.
 void tick(long timestamp)
          Called periodically by this media's manager to give it a chance to do its thing.
 
Methods inherited from class com.threerings.media.animation.Animation
addAnimationObserver, isFinished, removeAnimationObserver, reset, setLocation, willFinish, willStart
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, fastForward, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, shutdown, toString, toString, viewLocationDidChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_sprite

protected Sprite _sprite
The sprite associated with this animation.


_spritemgr

protected SpriteManager _spritemgr
The sprite manager managing our sprite.


_path

protected Path _path
The path along which we'll move our sprite.

Constructor Detail

SpriteAnimation

public SpriteAnimation(SpriteManager spritemgr,
                       Sprite sprite,
                       Path path)
Constructs a sprite animation for the given sprite. The first time the animation is ticked, the sprite will be added to the given sprite manager and started along the supplied path.

Method Detail

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

pathCancelled

public void pathCancelled(Sprite sprite,
                          Path path)
Description copied from interface: PathObserver
Called when a sprite's path is cancelled either because a new path was started or the path was explicitly cancelled with Sprite.cancelMove().

Specified by:
pathCancelled in interface PathObserver

pathCompleted

public void pathCompleted(Sprite sprite,
                          Path path,
                          long when)
Description copied from interface: PathObserver
Called when a sprite completes its traversal of a path.

Specified by:
pathCompleted in interface PathObserver
Parameters:
sprite - the sprite that completed its path.
path - the path that was completed.
when - the tick stamp of the media tick on which the path was completed (see FrameManager.tick(long)) (this may not be in the same time domain as System.currentTimeMillis()).

didFinish

protected void didFinish(long tickStamp)
Description copied from class: Animation
Called when the animation is finished and the animation manager has removed it from service.

Overrides:
didFinish in class Animation