Reputation: 23
Im using Property Animation to animate a swinging pendulum (single image). There's a button with click event which would increase the speed of the pendulum. Im unsure how I could achieve this. I understand that the duration of the animation is set by the call setDuration() which has an effect on the speed. Should setDuration() be used to change the speed of the animation during runtime? eg.
public void onAnimationUpdate(ValueAnimator animation) {
animator.setDuration(speed);
}
Where the property 'speed' is changed via the button's click event.
Am I on the right track or going off at a different tangent entirely?
Note: The pendulum should not be restarted. It should continue to swing with the updated speed when the button is clicked.
Upvotes: 2
Views: 1621
Reputation: 431
detect the min or max value of animation in update listener, and then use anim.cancel();
anim.setDuration(speed);
anim.start()
Upvotes: 1