com.threerings.media.animation
Class SpritePathAnimation

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

public class SpritePathAnimation
extends Animation
implements PathObserver

Wraps the dirty work of moving a sprite along a Path in an Animation.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.animation.Animation
Animation.AnimCompletedOp, Animation.AnimStartedOp
 
Field Summary
protected  Path _path
           
protected  Sprite _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
SpritePathAnimation(Sprite sprite, Path path)
           
 
Method Summary
 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 tickStamp)
          Called periodically by this media's manager to give it a chance to do its thing.
protected  void willStart(long tickStamp)
          Prior to the first call to AbstractMedia.tick(long) on an abstract media, this method is called by the AbstractMediaManager.
 
Methods inherited from class com.threerings.media.animation.Animation
addAnimationObserver, didFinish, isFinished, removeAnimationObserver, reset, setLocation, willFinish
 
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 final Sprite _sprite

_path

protected final Path _path
Constructor Detail

SpritePathAnimation

public SpritePathAnimation(Sprite sprite,
                           Path path)
Method Detail

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

tick

public void tick(long tickStamp)
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:
tickStamp - 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.

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()).

willStart

protected void willStart(long tickStamp)
Description copied from class: AbstractMedia
Prior to the first call to AbstractMedia.tick(long) on an abstract media, this method is called by the AbstractMediaManager. It is called during the normal tick cycle, immediately prior to the first call to AbstractMedia.tick(long).

Note: It is imperative that super.willStart() is called by any entity that overrides this method because the AbstractMediaManager depends on the setting of the AbstractMedia._firstTick value to know whether or not to call this method.

Overrides:
willStart in class Animation