From: Ricardo Cruz Date: Tue, 17 Aug 2004 23:23:11 +0000 (+0000) Subject: Changed next action behavior. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=be7f9f65018ed21515d389e8bd50f6f1eb988375;p=supertux.git Changed next action behavior. SVN-Revision: 1803 --- diff --git a/lib/special/sprite.cpp b/lib/special/sprite.cpp index be2b81f8e..6ffea6a04 100644 --- a/lib/special/sprite.cpp +++ b/lib/special/sprite.cpp @@ -98,17 +98,20 @@ Sprite::init_defaults(Action* act) void Sprite::set_action(std::string act) { +if(!next_action.empty() && animation_loops > 0) + { + next_action = act; + return; + } Actions::iterator i = actions.find(act); action = i->second; } void -Sprite::start_animation(int loops, std::string next_act) +Sprite::start_animation(int loops) { reset(); animation_loops = loops; -if(!next_act.empty()) - next_action = next_act; } void diff --git a/lib/special/sprite.h b/lib/special/sprite.h index 54f347641..4906aff5f 100644 --- a/lib/special/sprite.h +++ b/lib/special/sprite.h @@ -64,9 +64,8 @@ namespace SuperTux /* Start an animation -1 - for infinite 0 - stopped - 1,2,3 - one, two, three times... - If next_act specified, that action will be used when animation ends. */ - void start_animation(int loops, std::string next_act = ""); + 1,2,3 - one, two, three times... */ + void start_animation(int loops); /** Check if animation is stopped or not */ bool check_animation(); /** Reverse the animation */ @@ -117,7 +116,7 @@ namespace SuperTux Actions actions; Action* action; - std::string next_action; + std::string next_action; }; } //namespace SuperTux diff --git a/src/player.cpp b/src/player.cpp index 7f829722c..edd4b24b2 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -95,12 +95,12 @@ feet->set_action(action); } void -TuxBodyParts::start_animation(int loops, std::string next_action) +TuxBodyParts::one_time_animation() { -head->start_animation(loops, next_action); -body->start_animation(loops, next_action); -arms->start_animation(loops, next_action); -feet->start_animation(loops, next_action); +head->start_animation(1); +body->start_animation(1); +arms->start_animation(1); +feet->start_animation(1); } void @@ -826,12 +826,12 @@ Player::draw(DrawingContext& context) if (dir == RIGHT) { tux_body->set_action("idle-right"); - tux_body->start_animation(1, "stand-right"); + tux_body->one_time_animation(); } else { tux_body->set_action("idle-left"); - tux_body->start_animation(1, "stand-left"); + tux_body->one_time_animation(); } idle_timer.start(IDLE_TIME); } diff --git a/src/player.h b/src/player.h index 3cbeb2ed0..0897674e7 100644 --- a/src/player.h +++ b/src/player.h @@ -110,7 +110,7 @@ public: ~TuxBodyParts() { }; void set_action(std::string action); - void start_animation(int loops, std::string next_action = ""); + void one_time_animation(); void draw(DrawingContext& context, const Vector& pos, int layer, Uint32 drawing_effect = NONE_EFFECT);