diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2006-09-20 23:34:11 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2006-09-20 23:34:11 +0000 |
commit | 073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79 (patch) | |
tree | 1838ff9e6a2c54519f2b61af8d54388f2feabfde /src/animatedsprite.cpp | |
parent | 0d2c09435711a5bcb4dfbd7d7900de6c415361ee (diff) | |
download | mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.tar.gz mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.tar.bz2 mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.tar.xz mana-073d6ba7ad9f4052dcefd0fc64fd705b0e9c8f79.zip |
tweaks at the animation system (mostly about fixing the looping attack animations of the monsters)
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r-- | src/animatedsprite.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 36851366..e7439644 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -176,6 +176,10 @@ AnimatedSprite::AnimatedSprite(const std::string& animationFile, int variant): start++; } } + else if (xmlStrEqual(phaseNode->name, BAD_CAST "end")) + { + animation->addTerminator(); + }; } // for phaseNode } // for animationNode } // if "<imageset>" else if "<action>" @@ -268,7 +272,7 @@ AnimatedSprite::reset() } void -AnimatedSprite::play(SpriteAction action, int time) +AnimatedSprite::play(SpriteAction action) { ActionIterator i = mActions.find(action); @@ -282,23 +286,14 @@ AnimatedSprite::play(SpriteAction action, int time) if (mAction != i->second) { mAction = i->second; - mLastTime = 0; - } - - if (!mAction || !time) - mSpeed = 1.0f; - else { - Animation* animation= mAction->getAnimation(mDirection); - if (animation) { - int animationLength = animation->getLength(); - mSpeed = (float) animationLength / time; - } + //mAction->reset(); } } void AnimatedSprite::update(int time) { + bool notFinished = true; // Avoid freaking out at first frame or when tick_time overflows if (time < mLastTime || mLastTime == 0) mLastTime = time; @@ -308,9 +303,14 @@ AnimatedSprite::update(int time) { Animation *animation = mAction->getAnimation(mDirection); if (animation != NULL) { - animation->update((unsigned int)((time - mLastTime) * mSpeed));} + notFinished = animation->update((unsigned int)(time - mLastTime));} mLastTime = time; } + + if (!notFinished) + { + play(ACTION_STAND); + } } bool |