com.threerings.parlor.card.client
Class CardSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.media.sprite.ImageSprite
              extended by com.threerings.media.sprite.OrientableImageSprite
                  extended by com.threerings.media.sprite.FadableImageSprite
                      extended by com.threerings.parlor.card.client.CardSprite
All Implemented Interfaces:
com.threerings.media.util.Pathable, DirectionCodes, Shape
Direct Known Subclasses:
MicroCardSprite

public class CardSprite
extends com.threerings.media.sprite.FadableImageSprite

A sprite representing a playing card.


Nested Class Summary
 
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  Card _card
          The depicted card.
protected  boolean _draggable
          Whether or not the user can drag the card around the board.
protected  boolean _facingUp
          Whether or not the card is facing up.
protected  Card _flipCard
          The card which will be revealed when we're done flipping.
protected  long _flipDuration
          If flipping, how long the current flip should take (otherwise -1).
protected  long _flipStamp
          The timestamp for when we started flipping the card.
protected  CardPanel _panel
          The panel responsible for the sprite.
protected  double _scaleFactor
          The horizontal scale factor used while flipping the card.
 
Fields inherited from class com.threerings.media.sprite.FadableImageSprite
_alphaComposite, _fadeDelay, _fadeInDuration, _fadeOutDuration, _fadeStamp, _pathDuration
 
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.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
CardSprite(CardPanel panel, Card card)
          Creates a new upward-facing card sprite.
CardSprite(CardPanel panel, Card card, boolean facingUp)
          Creates a new card sprite.
 
Method Summary
 void flip(Card newCard, long duration)
          Flip the card from its current displayed card to the specified card.
 Card getCard()
          Returns the card being depicted.
 boolean isDraggable()
          Checks whether or not the user can drag this card.
 boolean isFacingUp()
          Checks whether this card is facing up or down.
 void paint(Graphics2D gfx)
           
 void setCard(Card card)
          Sets the card to depict.
 void setDraggable(boolean draggable)
          Sets whether or not the user can drag this card around the board.
 void setFacingUp(boolean facingUp)
          Turns this card up or down.
 void tick(long tickStamp)
           
protected  void updateMirage()
          Updates the mirage according to the current state.
 
Methods inherited from class com.threerings.media.sprite.FadableImageSprite
completeFadeIn, completeFadeOut, fadeIn, fadeOut, getAlpha, moveAndFadeIn, moveAndFadeInAndOut, moveAndFadeOut, pathCompleted, setAlpha
 
Methods inherited from class com.threerings.media.sprite.OrientableImageSprite
accomodateFrame, setOrientation
 
Methods inherited from class com.threerings.media.sprite.ImageSprite
hitTest, init, layout, setAnimationMode, setFrameIndex, setFrameRate, setFrames, setMirage, toString
 
Methods inherited from class com.threerings.media.sprite.Sprite
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, inside, intersects, isMoving, move, paintPath, pathBeginning, 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

_panel

protected CardPanel _panel
The panel responsible for the sprite.


_card

protected Card _card
The depicted card.


_facingUp

protected boolean _facingUp
Whether or not the card is facing up.


_draggable

protected boolean _draggable
Whether or not the user can drag the card around the board.


_scaleFactor

protected double _scaleFactor
The horizontal scale factor used while flipping the card.


_flipDuration

protected long _flipDuration
If flipping, how long the current flip should take (otherwise -1).


_flipStamp

protected long _flipStamp
The timestamp for when we started flipping the card.


_flipCard

protected Card _flipCard
The card which will be revealed when we're done flipping.

Constructor Detail

CardSprite

public CardSprite(CardPanel panel,
                  Card card)
Creates a new upward-facing card sprite.

Parameters:
panel - the panel responsible for the sprite
card - the card to depict (can be null, in which case the card back will be shown)

CardSprite

public CardSprite(CardPanel panel,
                  Card card,
                  boolean facingUp)
Creates a new card sprite.

Parameters:
panel - the panel responsible for the sprite
card - the card to depict
facingUp - whether or not the card should be facing up
Method Detail

setCard

public void setCard(Card card)
Sets the card to depict.

Parameters:
card - the new card

getCard

public Card getCard()
Returns the card being depicted.

Returns:
the current card

setFacingUp

public void setFacingUp(boolean facingUp)
Turns this card up or down.

Parameters:
facingUp - whether or not the card should be facing up

isFacingUp

public boolean isFacingUp()
Checks whether this card is facing up or down.

Returns:
true if the card is facing up, false if facing down

setDraggable

public void setDraggable(boolean draggable)
Sets whether or not the user can drag this card around the board.

Parameters:
draggable - whether or not the user can drag the card

isDraggable

public boolean isDraggable()
Checks whether or not the user can drag this card.

Returns:
true if the user can drag the card, false if not

flip

public void flip(Card newCard,
                 long duration)
Flip the card from its current displayed card to the specified card.


tick

public void tick(long tickStamp)
Overrides:
tick in class com.threerings.media.sprite.FadableImageSprite

paint

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

updateMirage

protected void updateMirage()
Updates the mirage according to the current state.