summaryrefslogtreecommitdiff
path: root/src/textparticle.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-24 14:40:39 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-24 14:40:39 +0300
commit965e0b59beaec007a2675ddaf11426acf30782f8 (patch)
tree73687de0cb3ab59eeb08e2137b3ac531d4a3f0cc /src/textparticle.cpp
parent0c3d18a076b2ac999f47500a76f5ebf3b1a722ed (diff)
downloadplus-965e0b59beaec007a2675ddaf11426acf30782f8.tar.gz
plus-965e0b59beaec007a2675ddaf11426acf30782f8.tar.bz2
plus-965e0b59beaec007a2675ddaf11426acf30782f8.tar.xz
plus-965e0b59beaec007a2675ddaf11426acf30782f8.zip
improve textparticle class.
Diffstat (limited to 'src/textparticle.cpp')
-rw-r--r--src/textparticle.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index 818ac7920..f983dbf98 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -39,13 +39,16 @@ TextParticle::TextParticle(Map *const map, const std::string &text,
mTextFont(font),
mColor(color),
mOutline(outline),
- mTextWidth(mTextFont->getWidth(mText) / 2)
+ mTextWidth(mTextFont ? mTextFont->getWidth(mText) / 2 : 1)
{
}
bool TextParticle::draw(Graphics *const graphics,
const int offsetX, const int offsetY) const
{
+ if (!mColor || !mTextFont)
+ return false;
+
BLOCK_START("TextParticle::draw")
if (!isAlive())
{
@@ -61,13 +64,13 @@ bool TextParticle::draw(Graphics *const graphics,
if (mFadeOut && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
{
- alpha = alpha * static_cast<float>(mLifetimeLeft)
+ alpha *= static_cast<float>(mLifetimeLeft)
/ static_cast<float>(mFadeOut);
}
if (mFadeIn && mLifetimePast < mFadeIn)
{
- alpha = alpha * static_cast<float>(mLifetimePast)
+ alpha *= static_cast<float>(mLifetimePast)
/ static_cast<float>(mFadeIn);
}