How to concatenate animations
juanm4 opened this issue · comments
Juanma commented
Hi, I want to know how to concatenate animations, I mean:
For example:
- I have two list of animations. Each list contain animations to play together.
2.I want to execute secuencially, first the list one (play together) and then execute the list two (play together).
I'm trying to execute this situation using listeners, but I don't know why doesn't work. This is my code:
final Point distance = new Point(Math.abs(pointPlane.distace(pointImage1).getX()), Math.abs(pointPlane.distace(pointImage1).getY()));
AnimatorSet set = new AnimatorSet();
set.playTogether(
Glider.glide(Skill.Linear, 700, ObjectAnimator.ofFloat(imagePlane, "translationY", 0, -1 * distance.getY())),
Glider.glide(Skill.Linear, 700, ObjectAnimator.ofFloat(imagePlane, "translationX", 0, distance.getX()))
);
set.setDuration(2000);
set.start();
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {}
@Override
public void onAnimationEnd(Animator animator) {
imagePlane.setX(pointImage1.getX());
imagePlane.setY(pointImage1.getY());
final Point distance = new Point(Math.abs(pointPlane.distace(pointImage2).getX()), Math.abs(pointPlane.distace(pointImage2).getY()));
AnimatorSet set2 = new AnimatorSet();
set2.playTogether(
Glider.glide(Skill.Linear, 700, ObjectAnimator.ofFloat(imagePlane, "translationY", 0, 30)),
Glider.glide(Skill.Linear, 700, ObjectAnimator.ofFloat(imagePlane, "translationX", 0, 30))
);
set2.setDuration(2000);
set2.start();
}
@Override
public void onAnimationCancel(Animator animator) {}
@Override
public void onAnimationRepeat(Animator animator) {}
});
Thanks in advance!