X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanimate.cpp;h=1eff05d569d1a09a76be45ea69dde9d09a7a522f;hb=7bf392aeb264c6f700e9df8d13a83c8c5da26fc7;hp=cd6cda1d8faee1ccca2f6ecdd7cf19abefbf0c1b;hpb=02613d179c906075a0ad05a3aae46b3811f322aa;p=libs%2Fdemoscene.git diff --git a/source/animate.cpp b/source/animate.cpp index cd6cda1..1eff05d 100644 --- a/source/animate.cpp +++ b/source/animate.cpp @@ -8,14 +8,17 @@ namespace DemoScene { Animate::Animate(): target(0), + target_obj(0), anim(0), stacked(false), player(0) { } -Animate::Animate(GL::Placeable &t, const GL::Animation &a, GL::AnimationPlayer &p): +Animate::Animate(GL::Placeable &t, const GL::Animation &a, GL::AnimationPlayer &p, bool s): target(&t), + target_obj(0), anim(&a), + stacked(s), player(&p) { } @@ -34,10 +37,25 @@ void Animate::start(float, float d) float speed = 1.0f; if(!anim->is_looping() && d) speed = (anim->get_duration()/Time::sec)/d; - if(stacked) - player->play_stacked(*target, *anim, speed); + if(target_obj) + { + if(stacked) + player->play_stacked(*target_obj, *anim, speed); + else + player->play(*target_obj, *anim, speed); + } else - player->play(*target, *anim, speed); + { + if(stacked) + player->play_stacked(*target, *anim, speed); + else + player->play(*target, *anim, speed); + } +} + +void Animate::end(float) +{ + player->stop(*target, *anim); } @@ -58,6 +76,7 @@ void Animate::Loader::animation(const string &n) void Animate::Loader::target(const string &n) { obj.target = &demo.get_thing(n); + obj.target_obj = dynamic_cast(obj.target); } } // namespace DemoScene