Dragonfly 4.19
A text-based game engine
|
Public Member Functions | |
Animation () | |
void | setSprite (Sprite *p_new_sprite) |
const Sprite * | getSprite () 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 |
virtual std::string | serialize (std::string attr="") |
virtual int | deserialize (std::string s) |
bool | isModified () const |
int | draw (Vector position) |
Private Attributes | |
Sprite * | m_p_sprite |
int | m_index |
int | m_slowdown_count |
std::string | m_name |
bool | m_modified |
df::Animation::Animation | ( | ) |
Animation constructor.
|
virtual |
Deserialize string to become attributes and apply.
Return 0 if no errors, else -1.
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.
int df::Animation::getIndex | ( | ) | const |
Get index of current Sprite frame to be displayed.
std::string df::Animation::getName | ( | ) | const |
Get Sprite name (in ResourceManager).
int df::Animation::getSlowdownCount | ( | ) | const |
Set animation slowdown count (-1 means stop animation).
bool df::Animation::isModified | ( | ) | const |
Return true if any attributes modified since last serialize.
|
virtual |
Serialize attributes to string.
e.g., sprite_name:saucer,sprite_transparency:0,sprite_index:2,... Default ("") is only attributes modified since last serialize(). If attr is "ALL" then serialize (modified or not). Clear modified attribute. Returns "" if nothing modified.
void df::Animation::setIndex | ( | int | new_index | ) |
Set index of current Sprite frame to be displayed.
void df::Animation::setName | ( | std::string | new_name | ) |
Set Sprite name (in ResourceManager).
void df::Animation::setSlowdownCount | ( | int | new_slowdown_count | ) |
Set animation slowdown count (-1 means stop animation).
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).
|
private |
Current index frame for Sprite.
|
private |
True if modified since serialize().
|
private |
Sprite name in ResourceManager.
|
private |
Slowdown counter (-1 means stop).