Changed next action behavior.
authorRicardo Cruz <rick2@aeiou.pt>
Tue, 17 Aug 2004 23:23:11 +0000 (23:23 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Tue, 17 Aug 2004 23:23:11 +0000 (23:23 +0000)
SVN-Revision: 1803

lib/special/sprite.cpp
lib/special/sprite.h
src/player.cpp
src/player.h

index be2b81f..6ffea6a 100644 (file)
@@ -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
index 54f3476..4906aff 100644 (file)
@@ -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
index 7f82972..edd4b24 100644 (file)
@@ -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);
     }
index 3cbeb2e..0897674 100644 (file)
@@ -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);