A
A
Alexander Kolmachikhin2019-07-02 15:41:14
Java
Alexander Kolmachikhin, 2019-07-02 15:41:14

How to implement sprite animation in android (for objects in the game)?

Before asking a question, I confess that I found several ways:

  • Take about 50 frames and write in xml in the desired sequence. I didn’t like this method right away, because I need to animate a hero who can change costumes, which means 50 frames for each image, and 10 costumes is more than 500 pictures!
  • Use ObjectAnimator. This is a pretty cool tool, but for the animation of the hero, his breathing of the movement of his arms and legs, he is clearly not suitable.
  • Use 1 file that contains all the frames glued together, and then programmatically cut this file and display frame by frame.

Now to my task. I need to animate a hero, and the animation is not very complex, but not so easy that ObjectAnimator can handle it. I'm not making a game, but characters are conceived in my application and they must be "alive" (they only have to stand and breathe, they don't need to run and kill monsters), as well as change their images / costumes.
I am using Spriter to create animation. It allows you to save the animation as:
- gif (gif)
- a bunch of separate frames (png)
- a bunch of frames glued into one file (png)
But how, having all this, can you make a competent hero animation on android using java? How do game developers do it .. and not games?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-07-02
@dollar

Usually they make a "bunch of frames glued into one file" on a 1024x1024 or 2048x2048 canvas.
Even larger size is bad.
Accordingly, in the spriter itself it is better to export as a "heap of individual frames". But! At the same time, you need to make your own small software that will convert readable XML (or JSON) from the sprite and individual images into your own animation format that is convenient for you.
In this case, it is necessary to take into account the possibility of changing clothes in advance. In the spriter, this is all possible (by replacing individual static images that are involved in the animation).
If you are using a specific engine, you may need to google a converter to a supported format.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question