summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-01 15:34:45 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-01 18:25:11 +0300
commit4e7096f15eba73e6ea28066df6ab389aab3f052c (patch)
treeba8902bd4b4f0137925ab98c89beaa6233a44a51 /src
parent6661187fdc8278c9f9a15c6cdb4d85301a3e548c (diff)
downloadplus-4e7096f15eba73e6ea28066df6ab389aab3f052c.tar.gz
plus-4e7096f15eba73e6ea28066df6ab389aab3f052c.tar.bz2
plus-4e7096f15eba73e6ea28066df6ab389aab3f052c.tar.xz
plus-4e7096f15eba73e6ea28066df6ab389aab3f052c.zip
Fix random opacity issue in complex sprites in software mode.
Diffstat (limited to 'src')
-rw-r--r--src/animatedsprite.cpp8
-rw-r--r--src/animatedsprite.h2
-rw-r--r--src/compoundsprite.cpp25
-rw-r--r--src/compoundsprite.h2
4 files changed, 27 insertions, 10 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 8ccdd61e5..0b9eb5ddd 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -298,3 +298,11 @@ const Image* AnimatedSprite::getImage() const
{
return mFrame ? mFrame->image : 0;
}
+
+void AnimatedSprite::setAlpha(float alpha)
+{
+ mAlpha = alpha;
+
+ if (mFrame && mFrame->image && mFrame->image->getAlpha() != mAlpha)
+ mFrame->image->setAlpha(mAlpha);
+}
diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index 6ccf2419a..e10e0f338 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -80,6 +80,8 @@ class AnimatedSprite : public Sprite
unsigned int getFrameCount() const;
+ virtual void setAlpha(float alpha);
+
private:
bool updateCurrentAnimation(unsigned int dt);
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 8f6f1f60a..f92358791 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -128,7 +128,6 @@ bool CompoundSprite::draw(Graphics* graphics, int posX, int posY) const
{
drawSprites(graphics, posX, posY);
}
-
return false;
}
@@ -380,15 +379,6 @@ void CompoundSprite::redraw() const
drawSpritesSDL(graphics, posX, posY);
-/*
- SpriteConstIterator it, it_end;
- for (it = begin(), it_end = end(); it != it_end; ++it)
- {
- if (*it)
- (*it)->draw(graphics, posX, posY);
- }
-*/
-
delete graphics;
graphics = 0;
@@ -409,3 +399,18 @@ void CompoundSprite::redraw() const
mNeedsRedraw = false;
}
+
+void CompoundSprite::setAlpha(float alpha)
+{
+ if (alpha != mAlpha)
+ {
+ SpriteConstIterator it, it_end;
+ for (it = begin(), it_end = end(); it != it_end; ++ it)
+ {
+ if (*it)
+ (*it)->setAlpha(alpha);
+ }
+
+ mAlpha = alpha;
+ }
+}
diff --git a/src/compoundsprite.h b/src/compoundsprite.h
index 9d5a42a1b..834ccd835 100644
--- a/src/compoundsprite.h
+++ b/src/compoundsprite.h
@@ -98,6 +98,8 @@ public:
*/
virtual unsigned int getFrameCount(unsigned int layer);
+ virtual void setAlpha(float alpha);
+
private:
void redraw() const;