CardSprite Class Reference

The sprite for a card on the canvas. More...

#include <cardsprite.h>

Inheritance diagram for CardSprite:

Inheritance graph
[legend]
Collaboration diagram for CardSprite:

Collaboration graph
[legend]
List of all members.

Public Types

enum  AnimationState {
  Idle, Turning, Moving, Removing,
  ShuffleMove
}
 Possible animation states of the sprite. More...

Public Member Functions

 CardSprite (const Suite suite, const CardType type, ThemeManager *theme, int advancePeriod, QGraphicsScene *scene)
 Constructor for the sprite.
virtual void changeTheme ()
 Main theme manager function.
void setFrontside ()
 Display the card front pixmap image.
void setBackside ()
 Display the card back pixmap image.
virtual void advance (int phase)
 Standard advance method.
void stop ()
 Stop all movment and animation.
void setTurning (bool front)
 Turn the card to frontside or backside.
void setMove (QPointF pos, double time)
 Move the sprite slowly to the target area.
void setPosition (QPointF pos)
 Set the position of the sprite.
void setRemove (QPointF pos, double time)
 Move the sprite slowly to the target area.
void setShuffleMove (QPointF pos, double delay, bool front)
 Delay before moving, then move the sprite fast to the target area.
void setFrame (int no, bool force=false)
 Set the current frame.
int count ()
 Retrieve the maximum frame number.
int cardid ()
 Retreive the card id, a combination of suite and card type.
int frame ()
 Retrieve the current frame number.

Protected Member Functions

void calcFrame (int no)
 Calculate a sprite frame (for turning sprites).
QPixmap createCard (const QPixmap front, const QPixmap back, int curNo, int count)
 Create the pixmap for one frame of the frame turning animation.
void calcTargetAndSpeed (QPointF pos, double time)
 Set target position and calculate moving speed.
bool deltaMove ()
 Perform a move by a delta given by the sprites velocity.

Detailed Description

The sprite for a card on the canvas.

Definition at line 38 of file cardsprite.h.


Member Enumeration Documentation

enum CardSprite::AnimationState
 

Possible animation states of the sprite.

Enumerator:
Idle 
Turning 
Moving 
Removing 
ShuffleMove 

Definition at line 52 of file cardsprite.h.


Constructor & Destructor Documentation

CardSprite::CardSprite const Suite  suite,
const CardType  type,
ThemeManager theme,
int  advancePeriod,
QGraphicsScene *  scene
 

Constructor for the sprite.

Parameters:
suite The suite of the card to use [Club, ...]
type The card type [Ace, ...]
theme The theme manager
advancePeriod The scene advance period [ms]
scene The scene object

Definition at line 45 of file cardsprite.cpp.

References Idle.


Member Function Documentation

void CardSprite::advance int  phase  )  [virtual]
 

Standard advance method.

Parameters:
phase Advance phase

Definition at line 281 of file cardsprite.cpp.

References ANIM_CNT_TURNING, deltaMove(), frame(), Idle, Moving, Removing, setFrame(), setTurning(), ShuffleMove, and Turning.

Here is the call graph for this function:

void CardSprite::calcFrame int  no  )  [protected]
 

Calculate a sprite frame (for turning sprites).

Called when the frame is asked for.

Parameters:
no The frame number.

Definition at line 223 of file cardsprite.cpp.

References ThemeManager::getCard(), ThemeManager::getCardback(), and Themable::thememanager().

Referenced by setFrame().

Here is the call graph for this function:

void CardSprite::calcTargetAndSpeed QPointF  pos,
double  time
[protected]
 

Set target position and calculate moving speed.

Parameters:
pos Target [0..1, 0..1]
time The movement speed [ms]

Definition at line 120 of file cardsprite.cpp.

References Themable::getScale().

Referenced by setMove(), setRemove(), and setShuffleMove().

Here is the call graph for this function:

int CardSprite::cardid  )  [inline]
 

Retreive the card id, a combination of suite and card type.

Returns:
The card id.

Definition at line 125 of file cardsprite.h.

void CardSprite::changeTheme  )  [virtual]
 

Main theme manager function.

Called when any theme change like a new theme or a theme size change occurs. This object needs to resiez and redraw then.

Implements Themable.

Definition at line 61 of file cardsprite.cpp.

References ThemeManager::config(), ThemeManager::getScale(), Themable::getScale(), Themable::setScale(), and Themable::thememanager().

Here is the call graph for this function:

int CardSprite::count  ) 
 

Retrieve the maximum frame number.

Returns:
The frame count.

Definition at line 192 of file cardsprite.cpp.

QPixmap CardSprite::createCard const QPixmap  front,
const QPixmap  back,
int  curNo,
int  count
[protected]
 

Create the pixmap for one frame of the frame turning animation.

Parameters:
front The front pixmap
back The back pixmap
curNo Which number in the animation sequence [0..count]
count How many frames in the animation
Returns:
The calculated pixmap.

Definition at line 359 of file cardsprite.cpp.

bool CardSprite::deltaMove  )  [protected]
 

Perform a move by a delta given by the sprites velocity.

Returns:
True if the target position is reached false otherwise.

Definition at line 258 of file cardsprite.cpp.

References Themable::getScale(), and setPosition().

Referenced by advance().

Here is the call graph for this function:

int CardSprite::frame  )  [inline]
 

Retrieve the current frame number.

Returns:
The frame number 0..n-1.

Definition at line 130 of file cardsprite.h.

Referenced by advance().

void CardSprite::setBackside  ) 
 

Display the card back pixmap image.

Definition at line 185 of file cardsprite.cpp.

References setFrame().

Referenced by AbstractDisplay::createCardSprites(), DisplayIntro::loop(), and stop().

Here is the call graph for this function:

void CardSprite::setFrame int  no,
bool  force = false
 

Set the current frame.

Parameters:
no The frame number 0..n-1
force Force redraw

Definition at line 200 of file cardsprite.cpp.

References calcFrame().

Referenced by advance(), setBackside(), and setFrontside().

Here is the call graph for this function:

void CardSprite::setFrontside  ) 
 

Display the card front pixmap image.

Definition at line 177 of file cardsprite.cpp.

References setFrame().

Here is the call graph for this function:

void CardSprite::setMove QPointF  pos,
double  time
 

Move the sprite slowly to the target area.

Stop movement if it arrived there.

Parameters:
pos Target position [0..1]
time Time for the move [ms]

Definition at line 147 of file cardsprite.cpp.

References calcTargetAndSpeed(), and Moving.

Referenced by DisplayTwo::play().

Here is the call graph for this function:

void CardSprite::setPosition QPointF  pos  ) 
 

Set the position of the sprite.

Parameters:
pos Target position [0..1]

Definition at line 138 of file cardsprite.cpp.

References Themable::getScale().

Referenced by DisplayTwo::deal(), deltaMove(), and DisplayIntro::loop().

Here is the call graph for this function:

void CardSprite::setRemove QPointF  pos,
double  time
 

Move the sprite slowly to the target area.

Stop movement and hide sprite if it arrived there.

Parameters:
pos Target position [0..1]
time Time for the move [ms]

Definition at line 157 of file cardsprite.cpp.

References calcTargetAndSpeed(), and Removing.

Referenced by DisplayTwo::remove().

Here is the call graph for this function:

void CardSprite::setShuffleMove QPointF  pos,
double  delay,
bool  front
 

Delay before moving, then move the sprite fast to the target area.

Stop movement and depending on the last argument turn backside/frontside sprite if it arrived there.

Parameters:
pos Target position [0..1]
delay The Move start delay [ms]
front Show frontside(true) or backside

Definition at line 167 of file cardsprite.cpp.

References calcTargetAndSpeed(), ShuffleMove, and SHUFFLEMOVE_TIME.

Referenced by DisplayTwo::deal().

Here is the call graph for this function:

void CardSprite::setTurning bool  front  ) 
 

Turn the card to frontside or backside.

Parameters:
front True (turn to frontside) or false (turn to backside)

Definition at line 111 of file cardsprite.cpp.

References Turning.

Referenced by advance(), DisplayIntro::loop(), and DisplayTwo::turn().

void CardSprite::stop  ) 
 

Stop all movment and animation.

Definition at line 102 of file cardsprite.cpp.

References Idle, and setBackside().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Tue May 1 09:34:40 2007 for LSkat by  doxygen 1.4.6