SpriteParticle constructor now takes an AnchorPoint for positioning the sprite
[supertux.git] / src / sprite / sprite.cpp
index 4d68980..7a32c3f 100644 (file)
@@ -100,7 +100,7 @@ Sprite::draw(DrawingContext& context, const Vector& pos, int layer)
   update();
 
   if((int)frame >= get_frames() || (int)frame < 0)
-    log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action_name() << std::endl;
+    log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action() << std::endl;
   else
     context.draw_surface(action->surfaces[(int)frame],
             pos - Vector(action->x_offset, action->y_offset),
@@ -120,7 +120,7 @@ Sprite::draw_part(DrawingContext& context, const Vector& source,
 #ifndef DEBUG
     // in optimized mode we get some small rounding errors in floating point
     // number sometimes...
-    log_warning << "frame out of range: " << frameidx << "/" << get_frames() << " at sprite: " << get_name() << "/" << get_action_name() << std::endl;
+    log_warning << "frame out of range: " << frameidx << "/" << get_frames() << " at sprite: " << get_name() << "/" << get_action() << std::endl;
 #endif
     frameidx = get_frames() - 1;
   }
@@ -142,6 +142,36 @@ Sprite::get_height() const
   return (int) action->surfaces[get_frame()]->get_height();
 }
 
+float
+Sprite::get_current_hitbox_x_offset() const
+{
+  return action->x_offset;
+}
+
+float
+Sprite::get_current_hitbox_y_offset() const
+{
+  return action->y_offset;
+}
+
+float
+Sprite::get_current_hitbox_width() const
+{
+  return action->hitbox_w;
+}
+
+float
+Sprite::get_current_hitbox_height() const
+{
+  return action->hitbox_h;
+}
+
+Rect
+Sprite::get_current_hitbox() const
+{
+  return Rect(action->x_offset, action->y_offset, action->x_offset + action->hitbox_w, action->y_offset + action->hitbox_h);
+}
+
 void
 Sprite::set_fps(float new_fps)
 {