From 7b599fad6cdbaa40f1cb496218dcd5546de7f520 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sun, 30 Jul 2006 15:19:45 +0000 Subject: Unified the play methods. --- src/animatedsprite.cpp | 18 +++++------------- src/animatedsprite.h | 11 +++-------- 2 files changed, 8 insertions(+), 21 deletions(-) (limited to 'src') 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 -- cgit v1.2.3-70-g09d2