Added next action to sprite.
[supertux.git] / lib / special / sprite.h
index 05db0c6..54f3476 100644 (file)
@@ -45,8 +45,6 @@ namespace SuperTux
         /** Frames per second */
         float fps;
 
-        int animation_loops;
-
         std::vector<Surface*> surfaces;
         };
 
@@ -63,21 +61,37 @@ namespace SuperTux
       /** Set action (or state) */
       void set_action(std::string act);
 
-      /* Handling animations */
-      void start_animation(int loops);
+      /* 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 = "");
+      /** Check if animation is stopped or not */
       bool check_animation();
+      /** Reverse the animation */
+      void reverse_animation();
 
       float get_fps()
         { return action->fps; }
+      /** Get current action total frames */
       int get_frames()
         { return action->surfaces.size(); }
+      /** Get sprite's name */
       std::string get_name() const
         { return name; }
+      /** Get current action name */
+      std::string get_action_name() const
+        { return action->name; }
       int get_width();
       int get_height();
 
-      int get_current_frame()
+      /** Get current frame */
+      int get_frame()
         { return (int)frame; }
+      /** Set current frame */
+      void set_frame(int frame_)
+        { if(frame_ > get_frames()) frame = 0; else frame = frame_; }
       Surface* get_frame(unsigned int frame)
       {
         if(frame < action->surfaces.size())
@@ -95,12 +109,15 @@ namespace SuperTux
       std::string name;
 
       float frame;
+      int animation_loops;
+      bool animation_reversed;
       float last_tick;
 
       typedef std::map <std::string, Action*> Actions;
       Actions actions;
 
       Action* action;
+      std::string next_action;
     };
 
 } //namespace SuperTux