Game Development Reference
In-Depth Information
This example code shows a fictional actor that is completely initialized and
manipulated via a chain of nested actions only. In this case, the added chain of
actions starts as a sequence of more actions. This being said, the sequence comprises
an absolute move action using
moveTo()
to a given point (
100
,
100
), followed
by an absolute rotation using
rotateTo()
(
0
degrees), followed by a short delay
of
1
second, and finally followed by a parallel action that contains a list of even
more actions. These parallel actions are a relative move using
moveBy()
(
50
,
0
)
and a relative rotation using
rotateBy()
(
90
degrees). Additionally, both actions
use a duration of
5
seconds. Moreover, the relative rotation uses the
swingOut
interpolation algorithm.
So, the combined use of the
Actor
and
Actions
classes provides a very powerful
way for us to express quite complex actor behaviors with relatively little code.
The next sections contain two lists with descriptions of the actions that are
currently available.
Actions for manipulating actors
The following list describes actions that are useful to manipulate actors:
•
add()
: This adds an action to an actor
•
alpha()
: This sets the alpha value of an actor's color
•
color()
: This sets the color of an actor
•
fadeIn()
and
fadeOut()
: These are convenience actions to set the alpha
value of an actor's color to
1
or
0
, respectively
•
hide()
: This sets the visibility of an actor to
false
•
layout()
: This sets the actor's layout to
enabled
or
disabled
•
moveBy()
and
moveTo()
: These move an actor by a relative amount or to a
specific location
•
removeActor()
: This removes the actor to which this action is attached;
alternatively, another actor that is to be removed can be specified
•
rotateBy()
and
rotateTo()
: These rotate an actor by a relative amount or
to a specific angle of rotation
•
run()
: This runs a
Runnable
(the code will be executed in a separate thread)
•
scaleBy()
and
scaleTo()
: These scale an actor by a relative amount or to a
specific scale