X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanimate.cpp;h=a7e406d73ae80c3428b5fe91d214820dffc645bf;hb=4b2708d0a743f74dfc44ea4e4c08344e09c624a6;hp=cd6cda1d8faee1ccca2f6ecdd7cf19abefbf0c1b;hpb=02613d179c906075a0ad05a3aae46b3811f322aa;p=libs%2Fdemoscene.git diff --git a/source/animate.cpp b/source/animate.cpp index cd6cda1..a7e406d 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,20 @@ 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); + } } @@ -58,6 +71,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