com.threerings.media.animation
Class AnimationSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.media.animation.AnimationSprite
All Implemented Interfaces:
Pathable, DirectionCodes, Shape

public class AnimationSprite
extends Sprite

A Sprite that wraps an animation so that a sequence of frames can be easily moved around the screen. Animations embedded here should not be added directly to a media panel as this sprite will manage them. If the enclosed animation completes, we remove the sprite from the media panel, since the animation would normally do that itself.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite
Sprite.CancelledOp, Sprite.CompletedOp
 
Field Summary
protected  Animation _anim
           
protected  MediaPanel _owner
           
 
Fields inherited from class com.threerings.media.sprite.Sprite
_orient, _ox, _oxoff, _oy, _oyoff, _path, _pathStamp
 
Fields inherited from class com.threerings.media.AbstractMedia
_bounds, _firstTick, _mgr, _observers, _renderOrder, HUD_LAYER
 
Fields inherited from interface com.threerings.util.DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST
 
Constructor Summary
AnimationSprite(Animation anim, MediaPanel owner)
           
 
Method Summary
 void init()
          Called when the media has had its manager set.
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 void setLocation(int x, int y)
          Set the location.
 void tick(long tickStamp)
          Called periodically by this media's manager to give it a chance to do its thing.
 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.sprite.Sprite
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, hitTest, inside, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setOrientation, shutdown, tickPath, toString, updateRenderOrigin, viewLocationDidChange
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.threerings.media.util.Pathable
getBounds
 

Field Detail

_anim

protected Animation _anim

_owner

protected MediaPanel _owner
Constructor Detail

AnimationSprite

public AnimationSprite(Animation anim,
                       MediaPanel owner)
Method Detail

init

public void init()
Description copied from class: AbstractMedia
Called when the media has had its manager set. Derived classes may override this method, but should be sure to call super.init().

Overrides:
init 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.

Overrides:
tick in class Sprite
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.

setLocation

public void setLocation(int x,
                        int y)
Description copied from class: AbstractMedia
Set the location.

Specified by:
setLocation in interface Pathable
Overrides:
setLocation in class Sprite

willStart

public 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 AbstractMedia

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.

Overrides:
paint in class Sprite