[LibGDX]Custom Animations

Hi. I recently tried to make animations with LibGDX and I was really disappointed by the limitations and I tried to create my own animation system.
It works as intended, but I’m not sure that I’m doing it the right way so I’m seeking you expertise.

Here is how it works:
Firstly, There is the Animation class that has all the basic informations like (position, id, textures, …) and the drawables, i will explain them later.
This class is mainly used to handle the ressources and be used in Drawables’ functions.

And then, there is the Drawable class, this one can be considered as a frame.
Each frame can react differently when ticked, rendered or when it ends, for example, it can wait until his ttl has ended and start other frames or simply end the animation. (This part is very basic for the moment, I’m adding stuff when needed).

And lastly, there is the AnimationController class, this one is used to interact with all the loaded Animations or to load/export a json file that contains all the informations about the animation.
It’s a sort of link between the game and the animations.

Source code:
I won’t include the source code in this thread as it would be too long.
Classes: Github.
Json example: Github.

Let me know what you think of it and if you don’t understand something in the code, I can explain it.

Also add in frame duration. It’s pretty important to have some frames be displayed longer/shorter than others without having to put in the same texture again.

Then, you did it right. ;D

Each frame has a timeToLive variable (ttl) that counts down when ticked.
However it is not required as the untilActionId can link to a condition that doesn’t require the ttl.
For example, a frame that is moving when ticked and that only finishes when it is out of the screen (Not implemented yet).

I like the “if it aint broke dont fix it” method, but I think there might be a better way to implement/use animations :slight_smile: