|
|||||||||
| 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.puzzle.drop.client.DropSprite
public class DropSprite
The drop sprite is a sprite that displays one or more pieces falling toward the bottom of the board.
| Nested Class Summary | |
|---|---|
protected static class |
DropSprite.PieceMovedOp
Used to dispatch DropSpriteObserver.pieceMoved(com.threerings.puzzle.drop.client.DropSprite, long, int, int). |
| Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite |
|---|
com.threerings.media.sprite.Sprite.CancelledOp, com.threerings.media.sprite.Sprite.CompletedOp |
| Field Summary | |
|---|---|
protected boolean |
_bouncing
Indicates that the drop sprite is bouncing; see setBouncing(boolean). |
protected int |
_col
The current piece location in the board. |
protected Point |
_destPos
The screen coordinates of the top-left of the row toward which the sprite is falling. |
protected int |
_dist
The number of rows remaining to drop. |
protected long |
_endstamp
The time at which we reached the end of the previous row. |
protected int |
_offx
The offsets in columns or rows at which the piece is rendered. |
protected int |
_offy
The offsets in columns or rows at which the piece is rendered. |
protected int[] |
_pieces
The pieces this sprite is displaying. |
protected Point |
_renderPos
The piece render position; used as working data when determining where to render each piece in the sprite. |
protected int |
_row
The current piece location in the board. |
protected long |
_rowstamp
The time at which we started the current row. |
protected Point |
_srcPos
The screen coordinates of the top-left of the row currently occupied by the sprite. |
protected long |
_stopstamp
The time at which we were stopped en route to our next row. |
protected int |
_unit
The unit distance the sprite moves to reach the next row. |
protected float |
_vel
The piece velocity. |
protected DropBoardView |
_view
The board view upon which this sprite is displayed. |
protected static float |
DEFAULT_VELOCITY
The default piece velocity. |
protected static int[] |
ORIENT_DX
|
protected static int[] |
ORIENT_DY
|
| 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 | |
|---|---|
DropSprite(DropBoardView view,
int col,
int row,
int[] pieces,
int dist)
Constructs a drop sprite and starts it dropping. |
|
DropSprite(DropBoardView view,
int col,
int row,
int[] pieces,
int dist,
int renderOrder)
Constructs a drop sprite and starts it dropping. |
|
| Method Summary | |
|---|---|
protected void |
advancePosition()
Called when the sprite has finished traversing its current row to advance its board coordinates to the next row. |
void |
drop()
Starts the piece dropping toward the next row. |
void |
fastForward(long timeDelta)
|
int |
getColumn()
Returns the column the piece is located in. |
int |
getDistance()
Returns the remaining number of columns to drop. |
float |
getPercentDone(long timestamp)
Returns a value between 0.0 and 1.0 representing how far the
piece has moved toward the next row as of the given time stamp. |
int[] |
getPieces()
Returns the pieces the sprite is displaying. |
int |
getRow()
Returns the row the piece is located in. |
float |
getVelocity()
Returns the velocity of this sprite. |
protected void |
init()
|
boolean |
inside(Shape shape)
|
boolean |
isBouncing()
Returns true if this sprite is bouncing. |
boolean |
isDropping()
Returns true if this drop sprite is dropping, false if it has been stop()ped or has
not yet been drop()ped. |
void |
paint(Graphics2D gfx)
|
protected void |
paintPieceImage(Graphics2D gfx,
int pieceidx,
int col,
int row,
int orient,
int x,
int y)
Paints the specified piece with the supplied parameters. |
void |
setBoardLocation(int row,
int col)
Sets the row and column the piece is located in. |
void |
setBouncing(boolean bouncing)
Puts the drop sprite into (or takes it out of) bouncing mode. |
void |
setColumn(int col)
Sets the column the piece is located in. |
void |
setColumnOffset(int count)
Sets the column offset of the sprite image. |
void |
setOrientation(int orient)
|
void |
setPieces(int[] pieces)
Sets the pieces the sprite is displaying. |
void |
setRow(int row)
Set the row the piece is located in. |
void |
setRowOffset(int count)
Sets the row offset of the sprite image. |
void |
setVelocity(float velocity)
Sets the velocity of this sprite. |
protected void |
shiftForBounce()
Updates the sprite's location to illustrate that it is currently in the "bouncing" state. |
void |
stop()
Stops the piece from dropping. |
void |
tick(long timestamp)
|
void |
toString(StringBuilder buf)
|
protected void |
updateBounds()
Updates the bounds for this sprite based on the sprite display dimensions in the view. |
protected void |
updatePosition()
Updates internal pixel coordinates used when the piece is moving. |
protected void |
updateRenderOffset()
Adjusts our render origin such that our location is not in the upper left of the sprite's rendered image but is in fact offset by some number of rows and columns. |
| Methods inherited from class com.threerings.media.sprite.Sprite |
|---|
addSpriteObserver, cancelMove, contains, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, hitTest, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setLocation, shutdown, tickPath, 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, 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 static final float DEFAULT_VELOCITY
protected long _rowstamp
protected long _endstamp
protected long _stopstamp
protected DropBoardView _view
protected int _unit
protected Point _srcPos
protected Point _destPos
protected Point _renderPos
protected int _dist
protected float _vel
protected int _offx
protected int _offy
protected int _row
protected int _col
protected int[] _pieces
protected boolean _bouncing
setBouncing(boolean).
protected static final int[] ORIENT_DX
protected static final int[] ORIENT_DY
| Constructor Detail |
|---|
public DropSprite(DropBoardView view,
int col,
int row,
int[] pieces,
int dist)
view - the board view upon which this sprite will be displayed.col - the column of the sprite.row - the row of the bottom-most piece.pieces - the pieces displayed by the sprite.dist - the distance the sprite is to drop in rows.
public DropSprite(DropBoardView view,
int col,
int row,
int[] pieces,
int dist,
int renderOrder)
view - the board view upon which this sprite will be displayed.col - the column of the sprite.row - the row of the bottom-most piece.pieces - the pieces displayed by the sprite.dist - the distance the sprite is to drop in rows.renderOrder - the render order.| Method Detail |
|---|
protected void init()
init in class com.threerings.media.AbstractMediapublic int getDistance()
public int getColumn()
public int getRow()
public int[] getPieces()
public float getVelocity()
public void setBoardLocation(int row,
int col)
public void setColumn(int col)
public void setRow(int row)
public void setColumnOffset(int count)
public void setRowOffset(int count)
public void setPieces(int[] pieces)
public void setVelocity(float velocity)
public void drop()
public boolean isDropping()
stop()ped or has
not yet been drop()ped.
public void stop()
public void setBouncing(boolean bouncing)
public boolean isBouncing()
protected void shiftForBounce()
public boolean inside(Shape shape)
inside in class com.threerings.media.sprite.Spritepublic float getPercentDone(long timestamp)
0.0 and 1.0 representing how far the
piece has moved toward the next row as of the given time stamp.
public void paint(Graphics2D gfx)
paint in class com.threerings.media.sprite.Sprite
protected void paintPieceImage(Graphics2D gfx,
int pieceidx,
int col,
int row,
int orient,
int x,
int y)
public void tick(long timestamp)
tick in class com.threerings.media.sprite.Spriteprotected void advancePosition()
public void fastForward(long timeDelta)
fastForward in class com.threerings.media.sprite.Spritepublic void toString(StringBuilder buf)
toString in class com.threerings.media.sprite.Spriteprotected void updatePosition()
public void setOrientation(int orient)
setOrientation in interface com.threerings.media.util.PathablesetOrientation in class com.threerings.media.sprite.Spriteprotected void updateBounds()
protected void updateRenderOffset()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||