summaryrefslogtreecommitdiff
path: root/src/animatedsprite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/animatedsprite.cpp')
-rw-r--r--src/animatedsprite.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 5a57b08c..1f8778e1 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -40,7 +40,8 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
mSprite(sprite),
mAction(0),
mAnimation(0),
- mFrame(0)
+ mFrame(0),
+ mAlpha(1.0f)
{
assert(mSprite);
@@ -142,9 +143,15 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time)
bool AnimatedSprite::draw(Graphics *graphics, int posX, int posY) const
{
- if (!mFrame || !mFrame->image)
+ if (!mFrame)
return false;
+ if (!mFrame->image)
+ return false;
+
+ if (mFrame->image->getAlpha() != mAlpha)
+ mFrame->image->setAlpha(mAlpha);
+
return graphics->drawImage(mFrame->image,
posX + mFrame->offsetX,
posY + mFrame->offsetY);
@@ -172,10 +179,16 @@ void AnimatedSprite::setDirection(SpriteDirection direction)
int AnimatedSprite::getWidth() const
{
- return mFrame ? mFrame->image->getWidth() : 0;
+ if (mFrame)
+ return mFrame->image ? mFrame->image->getWidth() : 0;
+ else
+ return 0;
}
int AnimatedSprite::getHeight() const
{
- return mFrame ? mFrame->image->getHeight() : 0;
+ if (mFrame)
+ return mFrame->image ? mFrame->image->getHeight() : 0;
+ else
+ return 0;
}