X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fmoving_sprite.cpp;h=0c746a5bd52345503ae218beb86693a325656e23;hb=5745d9670262c91e6cd35363fd0d2ec169e7c8a4;hp=aad264ac05e68439b2e85ce57260126cb66ac470;hpb=4a486d92343d1824b311c234e9321e08f280fe68;p=supertux.git diff --git a/src/object/moving_sprite.cpp b/src/object/moving_sprite.cpp index aad264ac0..0c746a5bd 100644 --- a/src/object/moving_sprite.cpp +++ b/src/object/moving_sprite.cpp @@ -135,3 +135,14 @@ MovingSprite::set_action_centered(const std::string& action, int loops) set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); set_pos(get_pos() - (bbox.get_size() - old_size) / 2); } + +void +MovingSprite::set_action(const std::string& action, int loops, AnchorPoint anchorPoint) +{ + Rect old_bbox = bbox; + sprite->set_action(action, loops); + float w = sprite->get_current_hitbox_width(); + float h = sprite->get_current_hitbox_height(); + set_size(w, h); + set_pos(get_anchor_pos(old_bbox, w, h, anchorPoint)); +}