Game Development Reference
In-Depth Information
In Layman's terms, what can be seen in each graph is a kind of lookup table. The
function of one of these algorithms takes the alpha value ( x axis) as its input
and outputs the corresponding interpolated value ( y axis). The actual output
simply depends on the algorithm's curve and what alpha value is used. The label
below each graph also denotes the name of the method, which you will find in
Interpolation . Also, note that each algorithm reverses its effect at an alpha value
of 0.5 . There are variants of each method for an algorithm in case you may want
to apply a certain effect on the first half ( alpha from 0.0 to 0.5 ) or on the second
one ( alpha from 0.5 to 1.0 ) only. This can be achieved using the In or Out suffix,
respectively, such as fadeIn , pow4In , and swingOut .
The basic usage of Interpolation looks as follows:
float alpha = 0.25f;
float interpolatedValue = Interpolation.elastic.apply(alpha);
This code example finds the interpolated value ( y axis) for a given alpha value ( x
axis) of 0.25 using the elastic algorithm. Remember, the alpha value can also be
interpreted as progress (here, 25 percent) of the overall effect.
With this in mind, we will now start to implement three distinct effects, namely fade,
slide, and slice.
Creating a fade transition effect
We will now create a fade transition effect that we will use to switch from the menu
screen to the game screen. In this effect, the next screen overlays the current screen
while gradually increasing the next screen's opacity. The opacity will start at 0
percent (fully translucent) and end at 100 percent (fully opaque).
The following sequence of screenshots shows this effect:
 
Search WWH ::




Custom Search