I would like to apply a onClick or OnTouch event in my animation

时间:2016-04-04 18:55:32

标签: android animation

I have an object(A ball for instance), I would like to apply an animation method so that my ball would start moving.. Now my problem is that, I want to create an OnClick listener or OnTouch Event on the ball, and response everytime the user touches the ball while the animation is still running.. Can you pls help me?

    TranslateAnimation animation = new TranslateAnimation(-100.0f, 400.0f, 0.0f, 0.0f);
    animation.setDuration(5000);
    animation.setRepeatMode(-1);
    image.startAnimation(animation);

    TranslateAnimation animation2 = new TranslateAnimation(-100.0f, 400.0f, 0.0f, 0.0f);
    animation.setDuration(5000);
    animation.setRepeatMode(-1);
    image2.startAnimation(animation2);

    TranslateAnimation animation3 = new TranslateAnimation(-100.0f, 400.0f, 0.0f, 0.0f);
    animation.setDuration(3000);
    animation.setRepeatMode(-1);
    image2.startAnimation(animation3);

0 个答案:

没有答案