From 4af405cd9dc675ef63ac4d993468f4868de85f6a Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Wed, 26 Jul 2006 13:48:36 +0000 Subject: Fixed direction and action issues when changing appeareance, frames are still out of sync. --- src/being.cpp | 4 ++-- src/being.h | 2 +- src/player.cpp | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 8a55f2e2..4256bdc7 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -164,9 +164,9 @@ Being::setMap(Map *map) } void -Being::setAction(Action action) +Being::setAction(Uint8 action) { - if (action != mAction) + //if (action != mAction) { std::string currentAction = "stand"; switch (action) diff --git a/src/being.h b/src/being.h index 478bc018..01b4fded 100644 --- a/src/being.h +++ b/src/being.h @@ -290,7 +290,7 @@ class Being : public Sprite /** * Sets the current action. */ - void setAction(Action action); + void setAction(Uint8 action); /** * Sets the current direction. diff --git a/src/player.cpp b/src/player.cpp index 9b7536cf..4e42e3c0 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -106,9 +106,14 @@ Player::setHairColor(Uint16 color) { if (color != mHairColor && mHairStyle > 0) { - delete mSprites[HAIR_SPRITE]; + if (mSprites[HAIR_SPRITE]) + { + delete mSprites[HAIR_SPRITE]; + } mSprites[HAIR_SPRITE] = new AnimatedSprite("graphics/sprites/hairstyle"+toString(mHairStyle)+".xml", color - 1); } + setDirection(mDirection); + setAction(mAction); Being::setHairColor(color); }; @@ -117,9 +122,14 @@ Player::setHairStyle(Uint16 style) { if (style != mHairStyle && mHairColor > 0) { - delete mSprites[HAIR_SPRITE]; + if (mSprites[HAIR_SPRITE]) + { + delete mSprites[HAIR_SPRITE]; + } mSprites[HAIR_SPRITE] = new AnimatedSprite("graphics/sprites/hairstyle"+toString(style)+".xml", mHairColor - 1); } + setDirection(mDirection); + setAction(mAction); Being::setHairStyle(style); }; @@ -147,10 +157,11 @@ Player::setVisibleEquipment(Uint8 slot, Uint8 id) if (id) { char stringId[4]; sprintf(stringId, "%03i", id); - printf("Id: %i %i %s\n", id, slot, stringId); mSprites[position] = new AnimatedSprite( "graphics/sprites/item" + toString(stringId) + ".xml", 0); } + setDirection(mDirection); + setAction(mAction); Being::setVisibleEquipment(slot, id); } -- cgit v1.2.3-70-g09d2