summaryrefslogtreecommitdiff
path: root/src/animatedsprite.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2009-09-17 02:14:12 +0200
committerBertram <bertram@cegetel.net>2009-09-17 02:14:12 +0200
commitfde41392cde408af9ea269e00336e503294dfdd2 (patch)
treefbdda716c1d441b7d85e686e054e3346396a144d /src/animatedsprite.cpp
parent78134dc88b0b39b0d051392fa937418bcd384404 (diff)
downloadmana-fde41392cde408af9ea269e00336e503294dfdd2.tar.gz
mana-fde41392cde408af9ea269e00336e503294dfdd2.tar.bz2
mana-fde41392cde408af9ea269e00336e503294dfdd2.tar.xz
mana-fde41392cde408af9ea269e00336e503294dfdd2.zip
Partially (but mainly) resolved Mantis #753 by making monsters, NPC, and Floor Items visible even covered.
Next Step would be to add a caching system for multi-layered sprites + copy functions for SDL and OpenGL. Then, I'll be able to finish this, by making also players visible when covered... But Kage asked me (each and every hour) to do something else first ;)
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;
}