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
/* 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 */
Actions actions;
Action* action;
- std::string next_action;
+ std::string next_action;
};
} //namespace SuperTux
}
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
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);
}
~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);