summaryrefslogtreecommitdiff
path: root/src/animatedsprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r--src/animatedsprite.cpp26
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