0
\$\begingroup\$

ValueAnimator sounds like an awesome way to animate values which can be used on views. But, somehow the animated values are not showing up as they should!

I used this set up before to animate a missile explosion for my upcoming view based Android game. It worked nice int the past, but now it does not! You can check the game here Astro Vs. Skully AND make sure to click on the white missile and follow instructions to see the animation played nicely!

I know the system is probably overloaded with tasks! And I have made this work by creating a long sequence of ValueAnimators played sequentially one after the other using an AnimatorSet. BUT, WHY DO I NEED TO CREATE MORE OBJECTS FOR THE GARBAGE COLLECTOR! NO NEED FOR THAT!

Here is the valueanimator I create that sadly its onAnimationUpdate method does not get the correct animated value, which makes it impossible to draw my explosion animation on the canvas.

ValueAnimator animatorr = ValueAnimator.ofFloat(25f,45f,90f,135,180f,225f,270f,315f,360f);
        animatorr.setDuration(1200);
        animatorr.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(@NonNull ValueAnimator valueAnimator) {
                Log.d("values_09326","See: " + (float)valueAnimator.getAnimatedValue());
            }
        });
        animatorr.start();

The log statements print out: 25f, 250f, 250.45f, 315f, 315.6f and so on! As you can see, the animated values DO NOT FOLLOW THE PATTERN OF NUMBERS! It's why Android animation is so tedious and I will be switching to LibGDX!

What have I tried! I read that you can reset the global frame refresh rate by doing this:

ValueAnimator.setFrameDelay(16); However, nothing happens!

I also clear the message queue of my handlers as such:

myHandler.removeCallbacksAndMessages(null); MainActivity.main_handler.removeCallbacksAndMessages(null); NOTHING HAPPENS!!

What is so funny about the android system is that I had 93 views on this view based game I am finishing soon AND the animation played so nicely with the overloaded views!

I brought down the count of views on the game by 10 or 12 AND THE ANIMATION NOW DOES NOT WORK AT ALL!!

How can I make this valueanimator print out the animated values as it should?

\$\endgroup\$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.