// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
+#include <stdexcept>
#include "moving_sprite.hpp"
#include "video/drawing_context.hpp"
sprite = new Sprite(*other.sprite);
}
-MovingSprite&
+MovingSprite&
MovingSprite::operator=(const MovingSprite& other)
{
if (this == &other) return *this;
sprite->draw(context, get_pos(), layer);
}
-void
+void
MovingSprite::update(float )
{
}
+void
+MovingSprite::set_action(const std::string& action, int loops)
+{
+ sprite->set_action(action, loops);
+ set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
+}
+void
+MovingSprite::set_action_centered(const std::string& action, int loops)
+{
+ Vector old_size = bbox.get_size();
+ sprite->set_action(action, loops);
+ set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
+ set_pos(get_pos() - (bbox.get_size() - old_size) / 2);
+}