For a successful game, animation effect is one of the indispensable elements of the game, then we will explain the use of animation classes.
First, Animation class
1, Animation introduction
The class is stored under the Com.badlogic.gdx.graphics.g2d package, which inherits from object.
2, animation definition
This is the official API definition, presumably means: an animation is stored in a list of pictures to show the sequence of time interval set. For example, a person who is running or is beating.
3, animation use
Manage animations and set the playback mode and playback order.
4. Animation usage
This is the constructor of the animation, and we'll explain the parameters in one at a while:
<1> float frameduration: The time interval to play each frame;
<2> array<? Extends textureregion> keyframes: Storing an array of animated pictures;
<3> int Playtype: Mode of playing animation, it provides 6 kinds of modes: NORMAL, reversed, LOOP, loop_reversed, Loop_pingpong, Loop_random:
①normal: normal playback mode;
②reversed: The direction play, from the back to play, this is like a character backwards running;
③loop: Continuous playback, this is more commonly used;
④loop_reversed: continuous backward playback;
⑤loop_pingpong: Play a few pictures forward, and then play a few frames back picture;
⑥loop_random: Continue to play immediately.
<4> textureregion ... keyframes: An array of images to store textureregion.
5, sample diagram