summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-20 01:48:55 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-01 21:16:53 +0300
commit1172c72401d6478f1fecc28ebccf335a99a51faf (patch)
treeb5b78f5ba1da0b90d1c0f5662a9f257882948bae
parent000eff105087e56b2d8d632c137fd82584aa8dd8 (diff)
downloadplus-1172c72401d6478f1fecc28ebccf335a99a51faf.tar.gz
plus-1172c72401d6478f1fecc28ebccf335a99a51faf.tar.bz2
plus-1172c72401d6478f1fecc28ebccf335a99a51faf.tar.xz
plus-1172c72401d6478f1fecc28ebccf335a99a51faf.zip
Fix tiles animation in opengl mode in non fringe layers.
-rw-r--r--src/map.cpp12
-rw-r--r--src/map.h6
-rw-r--r--src/simpleanimation.cpp8
-rw-r--r--src/simpleanimation.h2
4 files changed, 18 insertions, 10 deletions
diff --git a/src/map.cpp b/src/map.cpp
index d983508b1..b649922ae 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -95,13 +95,14 @@ TileAnimation::~TileAnimation()
mAnimation = nullptr;
}
-void TileAnimation::update(int ticks)
+bool TileAnimation::update(int ticks)
{
if (!mAnimation)
- return;
+ return false;
// update animation
- mAnimation->update(ticks);
+ if (!mAnimation->update(ticks))
+ return false;
// exchange images
Image *img = mAnimation->getCurrentImage();
@@ -115,6 +116,7 @@ void TileAnimation::update(int ticks)
}
mLastImage = img;
}
+ return true;
}
Map::Map(int width, int height, int tileWidth, int tileHeight):
@@ -306,8 +308,8 @@ void Map::update(int ticks)
iAni = mTileAnimations.begin();
iAni != mTileAnimations.end(); ++iAni)
{
- if (iAni->second)
- iAni->second->update(ticks);
+ if (iAni->second && iAni->second->update(ticks))
+ mRedrawMap = true;
}
}
diff --git a/src/map.h b/src/map.h
index 5b79ec8f5..53698ea03 100644
--- a/src/map.h
+++ b/src/map.h
@@ -75,10 +75,14 @@ class TileAnimation
{
public:
TileAnimation(Animation *ani);
+
~TileAnimation();
- void update(int ticks = 1);
+
+ bool update(int ticks = 1);
+
void addAffectedTile(MapLayer *layer, int index)
{ mAffected.push_back(std::make_pair(layer, index)); }
+
private:
std::vector<std::pair<MapLayer*, int> > mAffected;
SimpleAnimation *mAnimation;
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index 2b7cc328d..89431a916 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -93,11 +93,12 @@ void SimpleAnimation::setFrame(int frame)
mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
}
-void SimpleAnimation::update(int timePassed)
+bool SimpleAnimation::update(int timePassed)
{
if (!mCurrentFrame || !mAnimation)
- return;
+ return false;
+ bool updated(false);
if (mInitialized && mAnimation)
{
mAnimationTime += timePassed;
@@ -105,6 +106,7 @@ void SimpleAnimation::update(int timePassed)
while (mAnimationTime > mCurrentFrame->delay
&& mCurrentFrame->delay > 0)
{
+ updated = true;
mAnimationTime -= mCurrentFrame->delay;
mAnimationPhase++;
@@ -117,7 +119,7 @@ void SimpleAnimation::update(int timePassed)
mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
}
}
-
+ return updated;
}
int SimpleAnimation::getLength() const
diff --git a/src/simpleanimation.h b/src/simpleanimation.h
index de1203662..a7355a929 100644
--- a/src/simpleanimation.h
+++ b/src/simpleanimation.h
@@ -56,7 +56,7 @@ class SimpleAnimation
int getLength() const;
- void update(int timePassed);
+ bool update(int timePassed);
bool draw(Graphics *graphics, int posX, int posY) const;