com.threerings.puzzle.drop.client
Class DropSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.puzzle.drop.client.DropSprite
All Implemented Interfaces:
com.threerings.media.util.Pathable, com.threerings.util.DirectionCodes, Shape
Direct Known Subclasses:
DropBlockSprite

public class DropSprite
extends com.threerings.media.sprite.Sprite

The drop sprite is a sprite that displays one or more pieces falling toward the bottom of the board.


Field Summary
 
Fields inherited from class com.threerings.media.AbstractMedia
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
 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.
 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)
           
 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.
 void stop()
          Stops the piece from dropping.
 void tick(long timestamp)
           
 void toString(StringBuilder buf)
           
 
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, viewLocationDidChange
 
Methods inherited from class com.threerings.media.AbstractMedia
contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, queueNotification, renderCompareTo, setRenderOrder, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.threerings.media.util.Pathable
getBounds
 

Constructor Detail

DropSprite

public DropSprite(DropBoardView view,
                  int col,
                  int row,
                  int[] pieces,
                  int dist)
Constructs a drop sprite and starts it dropping.

Parameters:
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.

DropSprite

public DropSprite(DropBoardView view,
                  int col,
                  int row,
                  int[] pieces,
                  int dist,
                  int renderOrder)
Constructs a drop sprite and starts it dropping.

Parameters:
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

getDistance

public int getDistance()
Returns the remaining number of columns to drop.


getColumn

public int getColumn()
Returns the column the piece is located in.


getRow

public int getRow()
Returns the row the piece is located in.


getPieces

public int[] getPieces()
Returns the pieces the sprite is displaying.


getVelocity

public float getVelocity()
Returns the velocity of this sprite.


setBoardLocation

public void setBoardLocation(int row,
                             int col)
Sets the row and column the piece is located in.


setColumn

public void setColumn(int col)
Sets the column the piece is located in.


setRow

public void setRow(int row)
Set the row the piece is located in.


setColumnOffset

public void setColumnOffset(int count)
Sets the column offset of the sprite image.


setRowOffset

public void setRowOffset(int count)
Sets the row offset of the sprite image.


setPieces

public void setPieces(int[] pieces)
Sets the pieces the sprite is displaying.


setVelocity

public void setVelocity(float velocity)
Sets the velocity of this sprite. The time at which the current row was entered is modified so that the sprite position will remain the same when calculated using the new velocity since the piece sprite may have its velocity modified in the middle of a row traversal.


drop

public void drop()
Starts the piece dropping toward the next row.


isDropping

public boolean isDropping()
Returns true if this drop sprite is dropping, false if it has been stop()ped or has not yet been drop()ped.


stop

public void stop()
Stops the piece from dropping.


setBouncing

public void setBouncing(boolean bouncing)
Puts the drop sprite into (or takes it out of) bouncing mode. Bouncing mode is used to put the sprite into limbo after it lands but before we commit the landing, giving the user a last moment change move or rotate the piece. While the sprite is "bouncing" it will be rendered one pixel below its at rest state.


isBouncing

public boolean isBouncing()
Returns true if this sprite is bouncing.


inside

public boolean inside(Shape shape)
Overrides:
inside in class com.threerings.media.sprite.Sprite

getPercentDone

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


paint

public void paint(Graphics2D gfx)
Overrides:
paint in class com.threerings.media.sprite.Sprite

tick

public void tick(long timestamp)
Overrides:
tick in class com.threerings.media.sprite.Sprite

fastForward

public void fastForward(long timeDelta)
Overrides:
fastForward in class com.threerings.media.sprite.Sprite

toString

public void toString(StringBuilder buf)
Overrides:
toString in class com.threerings.media.sprite.Sprite

setOrientation

public void setOrientation(int orient)
Specified by:
setOrientation in interface com.threerings.media.util.Pathable
Overrides:
setOrientation in class com.threerings.media.sprite.Sprite


Copyright © 2011. All Rights Reserved.