A
A
AlexAlex0002021-02-18 21:55:52
Java
AlexAlex000, 2021-02-18 21:55:52

How to animate a bitmap correctly?

I can't figure out how to properly make a 2d animation of stretching the image to the left so that the right edge of the image remains in its place.
I found only one way: each iteration increase the width of the bitmap by 1 in the createScaledBitmap method and decrease its x by -1 in the drawBitmap method
But this method does not quite suit me, the fact is that changes in the Bitmap coordinates and its width occur in one thread, and the drawBitmap method is called in a separate SurfaceHolder thread. And almost constantly the picture is first drawn with the x position changed to -1, and only the next frame the picture is stretched. Even without erasing the fact that these two operations essentially go right after each other. Because of this, the animation turns out to be jerky, and this is clearly not what I would like. Are there any other options how to implement such an animation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question