libGDX:如何轻松改变动画速度?

时间:2013-09-29 12:42:35

标签: java animation libgdx

我正在为我的一个动画使用AnimationController,但我需要经常改变这个动画的速度。我正在寻找任何资源友好的方式,完美的将是AnimationController.setSpeed(float speed),但遗憾的是,这不存在。 那么,有没有比每次调用AinmationController.animate(...)更好的方法,当我只想改变速度而所有其他属性应该保持不变?

2 个答案:

答案 0 :(得分:2)

要更改整体速度,只需相应地调整更新方法的增量:

animationController.update(speed * Gdx.graphics.getDeltaTime());

要更改单个动画的速度(仅在混合动画时有用),请使用#animate()方法返回的AnimationDesc实例。

AnimationDesc ad = animationController.animate(...);
ad.speed = 0.5f;

您可以在动画期间更改AnimationDesc。

最后你也可以访问AnimationController的当前AnimationDesc,虽然我不推荐:

animationController.current.speed = 0.5f;

tl; dr:最好的方法是使用AnimationController#update(delta)方法来改变速度。

另请参阅:https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning

答案 1 :(得分:0)

我尝试扩展AnimationController来编写setSpeed方法。希望动画速度存储在您可以更新的变量中。

相关问题