Negative speed now plays an animation backwards

This commit is contained in:
Nehon 2018-03-26 06:29:20 +02:00
parent 7ded33051c
commit a463f5515a
2 changed files with 6 additions and 9 deletions

View File

@ -22,7 +22,10 @@ public abstract class Action implements Tween {
@Override
public boolean interpolate(double t) {
return subInterpolate(t * speed);
t = t * speed;
// make sure negative time is in [0, length] range
t = (t % length + length) % length;
return subInterpolate(t);
}
public abstract boolean subInterpolate(double t);

View File

@ -165,20 +165,14 @@ public class TestAnimMigration extends SimpleApplication {
composer.actionSequence("Sequence",
composer.makeAction("Walk"),
composer.makeAction("Run"),
composer.makeAction("Jumping")).setSpeed(4);
composer.makeAction("Jumping")).setSpeed(2);
action = composer.actionBlended("Blend", new LinearBlendSpace(1, 4),
"Walk", "Run");
action.getBlendSpace().setValue(1);
composer.action("Walk").setSpeed(2);
// composer.actionSequence("Sequence",
// composer.tweenFromClip("Walk"),
// composer.tweenFromClip("Dodge"),
// composer.tweenFromClip("push"));
composer.action("Walk").setSpeed(-1);
anims.addFirst("Sequence");
anims.addFirst("Blend");