summaryrefslogtreecommitdiff
path: root/src/being/compoundsprite.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-12-30 21:38:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-12-30 21:55:00 +0300
commit78e438b7043eff243a21833d4709ef432eb7a818 (patch)
treecbaace2b8a39c078115cd48c803363f7a274ee51 /src/being/compoundsprite.cpp
parent88efa77af94256992ba2c05f4d7b5b5a9d01d6e9 (diff)
downloadplus-78e438b7043eff243a21833d4709ef432eb7a818.tar.gz
plus-78e438b7043eff243a21833d4709ef432eb7a818.tar.bz2
plus-78e438b7043eff243a21833d4709ef432eb7a818.tar.xz
plus-78e438b7043eff243a21833d4709ef432eb7a818.zip
Fix animation time for new animated sprites.
Diffstat (limited to 'src/being/compoundsprite.cpp')
-rw-r--r--src/being/compoundsprite.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 5b37738b2..19311fc65 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -66,6 +66,8 @@ CompoundSprite::CompoundSprite() :
mAlphaImage(nullptr),
mOffsetX(0),
mOffsetY(0),
+ mStartTime(0),
+ mLastTime(0),
mSprites(),
#ifndef USE_SDL2
mNextRedrawTime(0),
@@ -93,6 +95,8 @@ bool CompoundSprite::reset()
if (*it)
ret |= (*it)->reset();
}
+ if (ret)
+ mLastTime = 0;
mNeedsRedraw |= ret;
return ret;
}
@@ -100,18 +104,28 @@ bool CompoundSprite::reset()
bool CompoundSprite::play(const std::string &action)
{
bool ret = false;
+ bool ret2 = true;
FOR_EACH (SpriteIterator, it, mSprites)
{
if (*it)
- ret |= (*it)->play(action);
+ {
+ const bool tmpVal = (*it)->play(action);
+ ret |= tmpVal;
+ ret2 &= tmpVal;
+ }
}
mNeedsRedraw |= ret;
+ if (ret2)
+ mLastTime = 0;
return ret;
}
bool CompoundSprite::update(const int time)
{
bool ret = false;
+ if (!mLastTime)
+ mStartTime = time;
+ mLastTime = time;
FOR_EACH (SpriteIterator, it, mSprites)
{
if (*it)
@@ -207,6 +221,8 @@ bool CompoundSprite::setSpriteDirection(const SpriteDirection::Type direction)
if (*it)
ret |= (*it)->setSpriteDirection(direction);
}
+ if (ret)
+ mLastTime = 0;
mNeedsRedraw |= ret;
return ret;
}
@@ -278,6 +294,7 @@ void CompoundSprite::clear()
delete_all(imagesCache);
imagesCache.clear();
delete2(mCacheItem);
+ mLastTime = 0;
}
void CompoundSprite::ensureSize(size_t layerCount)