X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsprite%2Fsprite.cpp;h=20c11fb5b99d5de0549da0be7cb21e346e8ffcef;hb=198f758764fff064a47630b5d0f1e3d6aabe95a8;hp=0841a0641f8f5de54572775f629382cd9d282198;hpb=fea3446f05e1e7673607b835c269d3e8d1929ab3;p=supertux.git diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index 0841a0641..20c11fb5b 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -75,6 +75,28 @@ Sprite::set_action(const std::string& name, int loops) frame = 0; } +void +Sprite::set_action_continued(const std::string& name) +{ + if(action && action->name == name) + return; + + SpriteData::Action* newaction = data.get_action(name); + if(!newaction) { + log_debug << "Action '" << name << "' not found." << std::endl; + return; + } + + action = newaction; + if(frame >= get_frames()) { + frame = fmodf(frame, get_frames()); + + if (animation_loops > 0) animation_loops--; + if(animation_done()) + frame = get_frames()-1; + } +} + bool Sprite::animation_done() {