From: Mikko Rasa Date: Sat, 8 Jun 2019 13:49:22 +0000 (+0300) Subject: Dynamically check for AnimatedObject in Animate X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5b734bb5eeef60ade61d7a3229d09644ebf34d3e;p=libs%2Fdemoscene.git Dynamically check for AnimatedObject in Animate --- diff --git a/source/animate.cpp b/source/animate.cpp index cd6cda1..c7eed38 100644 --- a/source/animate.cpp +++ b/source/animate.cpp @@ -34,10 +34,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 +68,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 diff --git a/source/animate.h b/source/animate.h index 30f0c52..50e279c 100644 --- a/source/animate.h +++ b/source/animate.h @@ -1,6 +1,7 @@ #ifndef MSP_DEMOSCENE_ANIMATE_H_ #define MSP_DEMOSCENE_ANIMATE_H_ +#include #include #include #include "action.h" @@ -23,6 +24,7 @@ public: private: Msp::GL::Placeable *target; + Msp::GL::AnimatedObject *target_obj; const Msp::GL::Animation *anim; bool stacked; Msp::GL::AnimationPlayer *player;