diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-24 14:40:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-24 14:40:39 +0300 |
commit | 965e0b59beaec007a2675ddaf11426acf30782f8 (patch) | |
tree | 73687de0cb3ab59eeb08e2137b3ac531d4a3f0cc /src | |
parent | 0c3d18a076b2ac999f47500a76f5ebf3b1a722ed (diff) | |
download | manaplus-965e0b59beaec007a2675ddaf11426acf30782f8.tar.gz manaplus-965e0b59beaec007a2675ddaf11426acf30782f8.tar.bz2 manaplus-965e0b59beaec007a2675ddaf11426acf30782f8.tar.xz manaplus-965e0b59beaec007a2675ddaf11426acf30782f8.zip |
improve textparticle class.
Diffstat (limited to 'src')
-rw-r--r-- | src/textparticle.cpp | 9 |
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); } |