summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-10-17 00:47:38 +0200
committerStefan Dombrowski <stefan@uni-bonn.de>2010-10-17 00:50:51 +0200
commit02a014605d19d0d38c14cafa462a2539d63950df (patch)
treeac831646a8e10f8972f6f3e2ed7cc7acfa7607c8 /src
parent9824ccf5946c86df1cf497b797c5f3da5d481d28 (diff)
downloadmana-02a014605d19d0d38c14cafa462a2539d63950df.tar.gz
mana-02a014605d19d0d38c14cafa462a2539d63950df.tar.bz2
mana-02a014605d19d0d38c14cafa462a2539d63950df.tar.xz
mana-02a014605d19d0d38c14cafa462a2539d63950df.zip
Fixed wrong alpha calculation of text particles
This resolves: http://bugs.manasource.org/view.php?id=51 Reviewed-by: Bertram
Diffstat (limited to 'src')
-rw-r--r--src/imageparticle.cpp10
-rw-r--r--src/particle.cpp13
-rw-r--r--src/particle.h3
-rw-r--r--src/textparticle.cpp10
4 files changed, 18 insertions, 18 deletions
diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp
index feb9548d..8ef2cce9 100644
--- a/src/imageparticle.cpp
+++ b/src/imageparticle.cpp
@@ -56,14 +56,6 @@ void ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
return;
}
- float alphafactor = mAlpha;
-
- if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
- alphafactor *= (float) mLifetimeLeft / (float) mFadeOut;
-
- if (mLifetimePast < mFadeIn)
- alphafactor *= (float) mLifetimePast / (float) mFadeIn;
-
- mImage->setAlpha(alphafactor);
+ mImage->setAlpha(getCurrentAlpha());
graphics->drawImage(mImage, screenX, screenY);
}
diff --git a/src/particle.cpp b/src/particle.cpp
index 84161c9f..0c4a7d7e 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -393,6 +393,19 @@ void Particle::adjustEmitterSize(int w, int h)
}
}
+float Particle::getCurrentAlpha() const
+{
+ float alpha = mAlpha;
+
+ if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
+ alpha *= (float)mLifetimeLeft / (float)mFadeOut;
+
+ if (mLifetimePast < mFadeIn)
+ alpha *= (float)mLifetimePast / (float)mFadeIn;
+
+ return alpha;
+}
+
void Particle::setMap(Map *map)
{
mMap = map;
diff --git a/src/particle.h b/src/particle.h
index 0690e8c4..69f8c2be 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -286,6 +286,9 @@ class Particle : public Sprite
{ return 1; }
protected:
+ /** Calculates the current alpha transparency taking current fade status into account*/
+ float getCurrentAlpha() const;
+
bool mAlive; /**< Is the particle supposed to be drawn and updated?*/
Vector mPos; /**< Position in pixels relative to map. */
int mLifetimeLeft; /**< Lifetime left in game ticks*/
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index e6226449..c9b5fc18 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -44,16 +44,8 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
int screenX = (int) mPos.x + offsetX;
int screenY = (int) mPos.y - (int) mPos.z + offsetY;
- float alpha = mAlpha * 255.0f;
-
- if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
- alpha = alpha * mLifetimeLeft / mFadeOut;
-
- if (mLifetimePast < mFadeIn)
- alpha = alpha * mLifetimePast / mFadeIn;
-
gcn::Color color = *mColor;
- color.a = (int)alpha;
+ color.a = getCurrentAlpha() * 255;
TextRenderer::renderText(graphics, mText,
screenX, screenY, gcn::Graphics::CENTER,