void Sprite::set_current_animation(const std::string& animation_name) { if(this->current_animation_name != animation_name) { SpriteAnimation* animation = current_animation_set.get_current_animation(animation_name); this->current_animation = animation; this->current_animation_name = animation_name; set_frame_delay(current_animation->get_frame_delay()); set_current_frame(0); } }
/** * \brief Sets the current animation of the sprite. * * If the sprite is already playing another animation, this animation is interrupted. * If the sprite is already playing the same animation, nothing is done. * * \param animation_name name of the new animation of the sprite */ void Sprite::set_current_animation(const std::string& animation_name) { if (animation_name != this->current_animation_name || !is_animation_started()) { this->current_animation_name = animation_name; this->current_animation = animation_set.get_animation(animation_name); set_frame_delay(current_animation->get_frame_delay()); set_current_frame(0, false); if (lua_context != NULL) { lua_context->sprite_on_animation_changed(*this, current_animation_name); lua_context->sprite_on_frame_changed(*this, current_animation_name, 0); } } }