Game Development Reference
In-Depth Information
Animations
In this chapter, you will learn how to create and manage different kinds of
animations using LibGDX's
Actions
and
Animation
classes. We will exemplify their
usage by animating certain parts of the menu and game screen.
With regards to the menu screen, we will create time-based and event-based
animations, including moving, scaling, and fading
Actor
objects via the so-called
actions of the
Actions
class. Additionally, interpolation algorithms provided by
LibGDX's
Interpolation
class will be used for added effects and for the smoothing
of these animations.
The game screen, in a sense, is already animated according to the game logic, which
takes care of coordinating the movement of every game object. However, each game
object is rendered using a still image. In terms of animations, this is equivalent to a
one-frame animation. With the help of the
Animation
class, we will define several
sequences of individual frames to form animations for our game objects.
Manipulating actors through actions
The
Actions
class offers a large collection of common actions to easily manipulate
the
Actor
objects. Besides action-specific parameters such as the position for a
move action, some actions also allow you to specify the duration as well as the
interpolation algorithm to be used. An action will always complete in an instant if
the duration is either omitted or set to
0
. Interpolation algorithms are provided by
LibGDX's
Interpolation
class.
For a quick overview of the available interpolation algorithms in
LibGDX, check out
Chapter 9
,
Screen Transitions
.