From 965e0b59beaec007a2675ddaf11426acf30782f8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 24 Mar 2013 14:40:39 +0300 Subject: improve textparticle class. --- src/textparticle.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/textparticle.cpp') 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(mLifetimeLeft) + alpha *= static_cast(mLifetimeLeft) / static_cast(mFadeOut); } if (mFadeIn && mLifetimePast < mFadeIn) { - alpha = alpha * static_cast(mLifetimePast) + alpha *= static_cast(mLifetimePast) / static_cast(mFadeIn); } -- cgit v1.2.3-70-g09d2