Dragonfly 4.20
A text-based game engine
Public Member Functions | Private Attributes | List of all members
df::Animation Class Reference

Public Member Functions

 Animation ()
 
void setSprite (Sprite *p_new_sprite)
 
const SpritegetSprite () const
 
void setName (std::string new_name)
 
std::string getName () const
 
void setIndex (int new_index)
 
int getIndex () const
 
void setSlowdownCount (int new_slowdown_count)
 
int getSlowdownCount () const
 
Box getBox () const
 
int serialize (std::stringstream *p_ss) const
 
int deserialize (std::stringstream *p_ss)
 
bool isModified () const
 
int draw (Vector position)
 
bool operator== (const Animation &a)
 
bool operator!= (const Animation &a)
 
std::string toString () const
 

Private Attributes

Spritem_p_sprite
 
int m_index
 
int m_slowdown_count
 
std::string m_name
 
bool m_modified
 

Constructor & Destructor Documentation

◆ Animation()

df::Animation::Animation ( )

Animation constructor.

Member Function Documentation

◆ deserialize()

int df::Animation::deserialize ( std::stringstream *  p_ss)

Deserialize attributes from stream.

Return 0 if ok, else -1.

◆ draw()

int df::Animation::draw ( Vector  position)

Draw single frame centered at position (x,y).

Drawing accounts for slowdown, and advances Sprite frame. Return 0 if ok, else -1.

◆ getBox()

Box df::Animation::getBox ( ) const

Get bounding box of associated Sprite.

◆ getIndex()

int df::Animation::getIndex ( ) const

Get index of current Sprite frame to be displayed.

◆ getName()

std::string df::Animation::getName ( ) const

Get Sprite name (in ResourceManager).

◆ getSlowdownCount()

int df::Animation::getSlowdownCount ( ) const

Set animation slowdown count (-1 means stop animation).

◆ getSprite()

const Sprite * df::Animation::getSprite ( ) const

Return pointer to associated Sprite.

◆ isModified()

bool df::Animation::isModified ( ) const

Return true if any attributes modified since last serialize.

◆ operator==()

bool df::Animation::operator== ( const Animation a)

Compare two Animations.

◆ serialize()

int df::Animation::serialize ( std::stringstream *  p_ss) const

Serialize attributes to stream.

Return 0 if ok, else -1.

◆ setIndex()

void df::Animation::setIndex ( int  new_index)

Set index of current Sprite frame to be displayed.

◆ setName()

void df::Animation::setName ( std::string  new_name)

Set Sprite name (in ResourceManager).

◆ setSlowdownCount()

void df::Animation::setSlowdownCount ( int  new_slowdown_count)

Set animation slowdown count (-1 means stop animation).

◆ setSprite()

void df::Animation::setSprite ( Sprite p_new_sprite)

Set associated Sprite to new one.

Note, Sprite is managed by ResourceManager. Set Sprite index to 0 (first frame).

◆ toString()

std::string df::Animation::toString ( ) const

Return attributes as string.

Member Data Documentation

◆ m_index

int df::Animation::m_index
private

Current index frame for Sprite.

◆ m_modified

bool df::Animation::m_modified
private

True if modified since serialize().

◆ m_name

std::string df::Animation::m_name
private

◆ m_p_sprite

Sprite* df::Animation::m_p_sprite
private

Sprite associated with Animation.

◆ m_slowdown_count

int df::Animation::m_slowdown_count
private

Slowdown counter (-1 means stop).