Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to concatenate animations #19

Open
juanm4 opened this issue Feb 22, 2018 · 0 comments
Open

How to concatenate animations #19

juanm4 opened this issue Feb 22, 2018 · 0 comments

Comments

@juanm4
Copy link

juanm4 commented Feb 22, 2018

Hi, I want to know how to concatenate animations, I mean:

For example:

  1. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant