]> git.tdb.fi Git - libs/demoscene.git/blobdiff - source/animate.cpp
Add stacked flag to Animate action
[libs/demoscene.git] / source / animate.cpp
index d74c23920da32b08c720f5cded62459e1f588ce5..cd6cda1d8faee1ccca2f6ecdd7cf19abefbf0c1b 100644 (file)
@@ -2,11 +2,14 @@
 #include "demo.h"
 
 using namespace std;
-using namespace Msp;
+
+namespace Msp {
+namespace DemoScene {
 
 Animate::Animate():
        target(0),
        anim(0),
+       stacked(false),
        player(0)
 { }
 
@@ -28,8 +31,13 @@ void Animate::validate() const
 
 void Animate::start(float, float d)
 {
-       float speed = (d ? (anim->get_duration()/Time::sec)/d : 1.0f);
-       player->play(*target, *anim, speed);
+       float speed = 1.0f;
+       if(!anim->is_looping() && d)
+               speed = (anim->get_duration()/Time::sec)/d;
+       if(stacked)
+               player->play_stacked(*target, *anim, speed);
+       else
+               player->play(*target, *anim, speed);
 }
 
 
@@ -38,6 +46,7 @@ Animate::Loader::Loader(Animate &a, Demo &d):
 {
        a.player = &demo.get_animation_player();
        add("animation", &Loader::animation);
+       add("stacked", &Animate::stacked);
        add("target", &Loader::target);
 }
 
@@ -50,3 +59,6 @@ void Animate::Loader::target(const string &n)
 {
        obj.target = &demo.get_thing<GL::Placeable>(n);
 }
+
+} // namespace DemoScene
+} // namespace Msp