Bonusblock and Bricks now break themself when hit by MrIceblock or Snail.
[supertux.git] / src / object / moving_sprite.cpp
index 3b3e7d7..853de73 100644 (file)
@@ -18,6 +18,7 @@
 //  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"
@@ -109,4 +110,19 @@ 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);
+}