|
|||||||||
| 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
public abstract class Sprite
The sprite class represents a single movable object in an animated view. A sprite has a position and orientation within the view, and can be moved along a path.
| Nested Class Summary | |
|---|---|
protected static class |
Sprite.CancelledOp
Used to dispatch PathObserver.pathCancelled(com.threerings.media.sprite.Sprite, com.threerings.media.util.Path). |
protected static class |
Sprite.CompletedOp
Used to dispatch PathObserver.pathCompleted(com.threerings.media.sprite.Sprite, com.threerings.media.util.Path, long). |
| Field Summary | |
|---|---|
protected int |
_orient
The orientation of this sprite. |
protected int |
_ox
The location of the sprite's origin in pixel coordinates. |
protected int |
_oxoff
The offsets from our upper left coordinate to our origin (or hot spot). |
protected int |
_oy
The location of the sprite's origin in pixel coordinates. |
protected int |
_oyoff
The offsets from our upper left coordinate to our origin (or hot spot). |
protected Path |
_path
When moving, the path the sprite is traversing. |
protected long |
_pathStamp
The timestamp at which we started along our path. |
| 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 | |
|---|---|
Sprite()
Constructs a sprite with an initially invalid location. |
|
Sprite(int width,
int height)
Constructs a sprite with the supplied dimensions. |
|
| Method Summary | |
|---|---|
void |
addSpriteObserver(Object obs)
Add a sprite observer to observe this sprite's events. |
void |
cancelMove()
Cancels any path that the sprite may currently be moving along. |
boolean |
contains(int x,
int y)
Returns true if the sprite's bounds contain the specified point, false if not. |
void |
fastForward(long timeDelta)
Called when the appropriate media manager has been paused for some length of time and is then unpaused. |
int |
getHeight()
Returns the sprite's height in pixels. |
int |
getOrientation()
Returns the sprite's orientation as one of the eight cardinal directions: DirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc. |
Path |
getPath()
Returns the path being followed by this sprite or null if the sprite is not following a path. |
int |
getWidth()
Returns the sprite's width in pixels. |
int |
getX()
Returns the sprite's x position in screen coordinates. |
int |
getXOffset()
Returns the offset to the sprite's origin from the upper-left of the sprite's image. |
int |
getY()
Returns the sprite's y position in screen coordinates. |
int |
getYOffset()
Returns the offset to the sprite's origin from the upper-left of the sprite's image. |
boolean |
hitTest(int x,
int y)
Returns true if the sprite's bounds contain the specified point, false if not. |
boolean |
inside(Shape shape)
Returns whether the sprite is inside the given shape in pixel coordinates. |
boolean |
intersects(Shape shape)
Returns whether the sprite's drawn rectangle intersects the given shape in pixel coordinates. |
boolean |
isMoving()
Returns true if this sprite is currently following a path, false if it is not. |
void |
move(Path path)
Set the sprite's active path and start moving it along its merry way. |
void |
paint(Graphics2D gfx)
Called by the appropriate manager to request that the media render itself with the given graphics context. |
void |
paintPath(Graphics2D gfx)
Paint the sprite's path, if any, to the specified 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. |
void |
removeSpriteObserver(Object obs)
Remove a sprite observer. |
void |
setLocation(int x,
int y)
Set the location. |
void |
setOrientation(int orient)
Sprites have an orientation in one of the eight cardinal directions: DirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc. |
protected void |
shutdown()
Called by the media manager after the media is removed from service. |
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 |
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. |
protected void |
updateRenderOrigin()
Update the coordinates at which the sprite image is drawn to reflect the sprite's current position. |
void |
viewLocationDidChange(int dx,
int dy)
Called by the AbstractMediaManager when we are in a VirtualMediaPanel that
just scrolled. |
| 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, 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 int _ox
_oxoff and _oyoff.
protected int _oy
_oxoff and _oyoff.
protected int _oxoff
protected int _oyoff
protected int _orient
protected Path _path
protected long _pathStamp
| Constructor Detail |
|---|
public Sprite()
public Sprite(int width,
int height)
| Method Detail |
|---|
public int getX()
getX in interface Pathablepublic int getY()
getY in interface Pathablepublic int getXOffset()
public int getYOffset()
public int getWidth()
public int getHeight()
public void setOrientation(int orient)
DirectionCodes.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 PathableDirectionCodespublic int getOrientation()
DirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc.
getOrientation in interface PathableDirectionCodes
public void setLocation(int x,
int y)
AbstractMedia
setLocation in interface PathablesetLocation in class AbstractMediapublic void paint(Graphics2D gfx)
AbstractMedia
paint in class AbstractMediapublic void paintPath(Graphics2D gfx)
gfx - the graphics context.
public boolean contains(int x,
int y)
public boolean hitTest(int x,
int y)
public boolean inside(Shape shape)
public boolean intersects(Shape shape)
public boolean isMoving()
public void move(Path path)
path - the path to follow.public void cancelMove()
public Path getPath()
public void pathBeginning()
pathBeginning in interface Pathablepublic void pathCompleted(long timestamp)
pathCompleted in interface Pathablepublic void tick(long tickStamp)
AbstractMedia
tick in class AbstractMediatickStamp - 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.protected boolean tickPath(long tickStamp)
public void fastForward(long timeDelta)
AbstractMedia
fastForward in class AbstractMediaprotected void updateRenderOrigin()
public void addSpriteObserver(Object obs)
obs - the sprite observer.public void removeSpriteObserver(Object obs)
public void viewLocationDidChange(int dx,
int dy)
AbstractMediaAbstractMediaManager when we are in a VirtualMediaPanel that
just scrolled.
viewLocationDidChange in class AbstractMediaprotected void shutdown()
AbstractMediasuper.shutdown().
shutdown in class AbstractMediaprotected void toString(StringBuilder buf)
AbstractMediasuper.toString()) to append the derived class
specific information to the string buffer.
toString in class AbstractMedia
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||