|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.media.AbstractMedia
com.threerings.media.sprite.Sprite
com.threerings.media.sprite.ImageSprite
com.threerings.cast.CharacterSprite
public class CharacterSprite
A character sprite is a sprite that animates itself while walking about in a scene.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite |
|---|
Sprite.CancelledOp, Sprite.CompletedOp |
| Field Summary | |
|---|---|
protected String |
_action
The action we are currently displaying. |
protected ActionFrames |
_aframes
The animation frames for the active action sequence in each orientation. |
protected CharacterManager |
_charmgr
A reference to the character manager that created us. |
protected CharacterDescriptor |
_descrip
A reference to the descriptor for the character that we're visualizing. |
protected String |
_followingPathAction
The action to use when following a path. |
protected Rectangle |
_ibounds
The bounds of the current sprite image. |
protected Point |
_ioff
The offset from the upper-left of the total sprite bounds to the upper-left of the image within those bounds. |
protected String |
_restingAction
The action to use when at rest. |
| Fields inherited from class com.threerings.media.sprite.ImageSprite |
|---|
_animMode, _firstStamp, _frameDelay, _frameIdx, _frames, DEFAULT_FRAME_RATE, MOVEMENT_CUED, NO_ANIMATION, TIME_BASED, TIME_SEQUENTIAL |
| 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.cast.StandardActions |
|---|
CROP_TYPE, SHADOW_TYPE, STANDING, WALKING |
| 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 | |
|---|---|
CharacterSprite()
|
|
| Method Summary | |
|---|---|
protected void |
accomodateFrame(int frameIdx,
int width,
int height)
Must adjust the bounds to accommodate the our new frame. |
void |
cancelMove()
Cancels any path that the sprite may currently be moving along. |
protected void |
compositeActionFrames()
Called to recomposite our action frames if needed. |
protected void |
decorateBehind(Graphics2D gfx)
Called to paint any decorations that should appear behind the character sprite image. |
protected void |
decorateInFront(Graphics2D gfx)
Called to paint any decorations that should appear in front of the character sprite image. |
protected void |
didInit()
Called after this sprite has been initialized with its character descriptor and character manager. |
String |
getFollowingPathAction()
Returns the action to be used when the sprite is following a path. |
String |
getRestingAction()
Returns the action to be used when the sprite is at rest. |
protected void |
halt()
Updates the sprite animation frame to reflect the cessation of movement and disables any further animation. |
boolean |
hitTest(int x,
int y)
Returns true if the sprite's bounds contain the specified point, and if there is a non-transparent pixel in the sprite's image at the specified point, false if not. |
void |
init(CharacterDescriptor descrip,
CharacterManager charmgr)
Initializes this character sprite with the specified character descriptor and character manager. |
void |
paint(Graphics2D gfx)
Called by the appropriate manager to request that the media render itself with the given graphics context. |
void |
pathBeginning()
Called by the active path when it begins. |
void |
pathCompleted(long timestamp)
Called by the active path when it has completed. |
protected void |
sanityCheckDescrip()
Makes it easier to track down problems with bogus character descriptors. |
void |
setActionSequence(String action)
Sets the action sequence used when rendering the character, from the set of available sequences. |
void |
setCharacterDescriptor(CharacterDescriptor descrip)
Reconfigures this sprite to use the specified character descriptor. |
void |
setFollowingPathAction(String action)
Specifies the action to use when the sprite is following a path. |
void |
setOrientation(int orient)
Sprites have an orientation in one of the eight cardinal directions: DirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc. |
void |
setRestingAction(String action)
Specifies the action to use when the sprite is at rest. |
void |
tick(long tickStamp)
Called periodically by this media's manager to give it a chance to do its thing. |
protected boolean |
tickPath(long tickStamp)
Ticks any path assigned to this sprite. |
protected void |
unionDecorationBounds(Rectangle bounds)
Called by accomodateFrame(int, int, int) to give derived classes an opportunity to incorporate
the bounds of any decorations that will be drawn along with this sprite. |
protected void |
updateActionFrames()
Rebuilds our action frames given our current character descriptor and action sequence. |
protected void |
updateRenderOrigin()
Update the coordinates at which the sprite image is drawn to reflect the sprite's current position. |
| Methods inherited from class com.threerings.media.sprite.ImageSprite |
|---|
init, layout, setAnimationMode, setFrameIndex, setFrameRate, setFrames, setMirage, toString |
| Methods inherited from class com.threerings.media.sprite.Sprite |
|---|
addSpriteObserver, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, inside, intersects, isMoving, move, paintPath, removeSpriteObserver, setLocation, shutdown, 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, willStart |
| 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 |
|---|
protected String _restingAction
protected String _followingPathAction
protected CharacterDescriptor _descrip
protected CharacterManager _charmgr
protected String _action
protected ActionFrames _aframes
protected Point _ioff
protected Rectangle _ibounds
| Constructor Detail |
|---|
public CharacterSprite()
| Method Detail |
|---|
public void init(CharacterDescriptor descrip,
CharacterManager charmgr)
protected void didInit()
public void setCharacterDescriptor(CharacterDescriptor descrip)
public void setRestingAction(String action)
STANDING.
public String getRestingAction()
public void setFollowingPathAction(String action)
WALKING.
public String getFollowingPathAction()
public void setActionSequence(String action)
public void setOrientation(int orient)
SpriteDirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc. Derived classes can
choose to override this member function and select a different set of images based on their
orientation, or they can ignore the orientation information.
setOrientation in interface PathablesetOrientation in class SpriteDirectionCodes
public boolean hitTest(int x,
int y)
ImageSprite
hitTest in class ImageSpritepublic void tick(long tickStamp)
AbstractMedia
tick in class ImageSpritetickStamp - 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.public void cancelMove()
Sprite
cancelMove in class Spritepublic void pathBeginning()
Sprite
pathBeginning in interface PathablepathBeginning in class Spritepublic void pathCompleted(long timestamp)
Sprite
pathCompleted in interface PathablepathCompleted in class Spritepublic void paint(Graphics2D gfx)
AbstractMedia
paint in class ImageSpriteprotected void decorateBehind(Graphics2D gfx)
protected void decorateInFront(Graphics2D gfx)
protected void updateActionFrames()
protected final void compositeActionFrames()
protected void sanityCheckDescrip()
protected boolean tickPath(long tickStamp)
Sprite
tickPath in class Spriteprotected void updateRenderOrigin()
Sprite
updateRenderOrigin in class Sprite
protected void accomodateFrame(int frameIdx,
int width,
int height)
ImageSpriteSprite.updateRenderOrigin() to reflect those changes in the
sprite's bounds.
accomodateFrame in class ImageSpriteframeIdx - the index of our new frame.width - the width of the new frame.height - the height of the new frame.protected void unionDecorationBounds(Rectangle bounds)
accomodateFrame(int, int, int) to give derived classes an opportunity to incorporate
the bounds of any decorations that will be drawn along with this sprite. The
_ibounds rectangle will contain the bounds of the image that comprises the
undecorated sprite. From that the position and size of decorations can be computed and
unioned with the supplied bounds rectangle (most likely by using
SwingUtilities.computeUnion(int, int, int, int, java.awt.Rectangle) which applies the union in place rather than creating a
new rectangle).
protected void halt()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||