summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-05-31 18:35:34 +0300
committerAndrei Karas <akaras@inbox.ru>2012-05-31 18:35:34 +0300
commit9875c00dc37b1d7b55e1154075a0cd2d997a490d (patch)
tree8560f7c7977f1df1a5465a22c00395df9967c702
parent02677a3b9b3abefb84e24023697466c892c6ded4 (diff)
downloadmv-9875c00dc37b1d7b55e1154075a0cd2d997a490d.tar.gz
mv-9875c00dc37b1d7b55e1154075a0cd2d997a490d.tar.bz2
mv-9875c00dc37b1d7b55e1154075a0cd2d997a490d.tar.xz
mv-9875c00dc37b1d7b55e1154075a0cd2d997a490d.zip
Add hurt animation.
-rw-r--r--src/being.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 8414d93a6..f1a3e0169 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -740,8 +740,12 @@ void Being::handleAttack(Being *victim, int damage,
if (dir)
setDirection(dir);
}
- if (damage && victim->mType == PLAYER && victim->mAction == SIT)
- victim->setAction(STAND);
+ if (damage)
+ {
+ victim->setAction(HURT);
+ if (this == player_node && mAction == HURT)
+ setAction(ATTACK);
+ }
sound.playSfx(mInfo->getSound((damage > 0) ?
SOUND_EVENT_HIT : SOUND_EVENT_MISS), mX, mY);
@@ -1068,10 +1072,7 @@ void Being::setAction(Action action, int attackType A_UNUSED)
case HURT:
if (mInfo)
sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT), mX, mY);
- //currentAction = SpriteAction::HURT;// Buggy: makes the player stop
- // attacking and unable to attack
- // again until he moves.
- // TODO: fix this!
+ currentAction = SpriteAction::HURT;
break;
case DEAD:
currentAction = SpriteAction::DEAD;