diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-07-30 15:19:45 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-07-30 15:19:45 +0000 |
commit | 7b599fad6cdbaa40f1cb496218dcd5546de7f520 (patch) | |
tree | 36222d32c9b56701be663dad80e06af47acd78d2 | |
parent | b280c89bbc8a3c12e45c3907166cc79e45fcf66d (diff) | |
download | mana-7b599fad6cdbaa40f1cb496218dcd5546de7f520.tar.gz mana-7b599fad6cdbaa40f1cb496218dcd5546de7f520.tar.bz2 mana-7b599fad6cdbaa40f1cb496218dcd5546de7f520.tar.xz mana-7b599fad6cdbaa40f1cb496218dcd5546de7f520.zip |
Unified the play methods.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/animatedsprite.cpp | 18 | ||||
-rw-r--r-- | src/animatedsprite.h | 11 |
3 files changed, 13 insertions, 21 deletions
@@ -1,3 +1,8 @@ +2006-07-30 Björn Steinbrink <B.Steinbrink@gmx.de> + + * src/animatedsprite.h, src/animatedsprite.cpp: Unified the play + methods. + 2006-07-30 Philipp Sehmisch <tmw@crushnet.org> * data/maps/new_5-1.tmx.gz: Fixed two minor mapping errors (no new diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 25525a69..9c82bf7a 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -228,7 +228,7 @@ AnimatedSprite::~AnimatedSprite() } void -AnimatedSprite::play(const std::string& action) +AnimatedSprite::play(const std::string& action, int time) { ActionIterator i = mActions.find(action); @@ -245,18 +245,10 @@ AnimatedSprite::play(const std::string& action) mLastTime = 0; } - mSpeed = 1.0f; -} - -void -AnimatedSprite::play(const std::string& action, int time) -{ - play(action); - - if (mAction != NULL) - { - Animation *animation = mAction->getAnimation(mDirection); - int animationLength = animation->getLength(); + if (!mAction || !time) + mSpeed = 1.0f; + else { + int animationLength = mAction->getAnimation(mDirection)->getLength(); mSpeed = (float) animationLength / time; } } diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 32466de8..4ef1d9f7 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -51,16 +51,11 @@ class AnimatedSprite ~AnimatedSprite(); /** - * Sets a new action using the current direction. + * Plays an action using the current direction that will have a + * duration of the specified time, 0 means default. */ void - play(const std::string& action); - - /** - * Plays an action in a specified time. - */ - void - play(const std::string& action, int time); + play(const std::string& action, int time = 0); /** * Inform the animation of the passed time so that it can output the |