In my third video, Rendering animated images in LibGdx, I show how LibGdx has a TextureRegion for splitting the cells of an animation sequence. I demonstrate the Animation class and how setting the PlayMode, you can achieve different looping techniques. There are LOOP, LOOP_PINGPONG, LOOP_RANDOM, LOOP_REVERSED, NORMAL and REVERSED. It is nice to have that in a single class. One feature that I didn’t see, was having it loop a set number of times. I show how to implement that manually, by using the getKeyFrame() and passing in a boolean for continuous looping. You have to manually keep track of the number of loops.
I then move on to the additional parameters to the getKeyFrame() method for resizing, by passing in additional values for the size in pixels you want the image to appear at. Then, I show the rotation, including setting the origin, and show you how the rotation degree affects the resulting image. I then show how the rotation with the counter-clockwise boolean, and how the size (height and width) are flipped in this implementation. I find it odd that with the counter-clockwise rotation, they change the height and width direction from the source image. Not what I would expect from just setting the direction to counter-clockwise.
I finish off this video with a character walking around the screen and what is involved in coding that.
In the fourth video, Creating an Animation Framework for LibGdx, I build a framework around the Animation of images, to simplify the entire process. This is based on the Animation framework I used in my Old Style Game Framework. I start with rending a single image in the StaticAnimation class. I move the values from the method parameters into class attributes, thus removing complexity in just drawing an image on the screen. This also give flexibility to easily change the size and orientation of a single image.
Finally, in my fifth video, Updating the Animation Framework for LibGdx, I build out a BaseAnimation class for storing common attributes and extend it with three classes: LoopAnimation, BounceAnimation, and RandomAnimation. The LoopAnimation handles going through the sequence any number of times, one to many times. Also, handling the “ping-pong” animation, bouncing forward and backward. Again, the changing of the size and rotation are the same methods as in the StaticAnimation. This gives us a familiar framework between different types of animating. Having common ways of changing an animation’s size and rotation makes working with the classes easier. It also removes the multi-parameter method out of sight. As an additional feature, I have the animation loop, or bounce, a set number of times as well.
I will enhance the framework in the sixth video, which will simplify the animation of a character walking.