gpt4 book ai didi

java - libGDX:如何轻松更改动画速度?

转载 作者:行者123 更新时间:2023-12-02 06:41:47 26 4
gpt4 key购买 nike

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

最佳答案

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

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

关于java - libGDX:如何轻松更改动画速度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19078161/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com