I'm using an AnimationController for one of my animations, but I need to vary the speed of this animation very often. I'm looking for any resource-friendly way to do so, perfect would be something like AnimationController.setSpeed(float speed)
, but sadly that doesn't exist. So, is there any better way than calling AinmationController.animate(...)
every time, when I only want to change the speed and all other properties should stay the same?
To change the overall speed, simply adjust the delta of the update method accordingly:
animationController.update(speed * Gdx.graphics.getDeltaTime());
To change the speed of a single animation (only useful when blending animations), use the AnimationDesc instance the #animate() method returns.
AnimationDesc ad = animationController.animate(...);
ad.speed = 0.5f;
You can change the AnimationDesc during the animation.
Finally you can also access the current AnimationDesc of the AnimationController, although I wouldn't recommend that:
animationController.current.speed = 0.5f;
tl;dr: The best method is to use the AnimationController#update(delta) method to change the speed.
See also: https://github.com/libgdx/libgdx/wiki/3D-animations-and-skinning
I'd try extending AnimationController
to write the setSpeed
method. Hopefully, animation speed will be stored in a variable that you could just update.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.