Game Development Reference
In-Depth Information
Lastly, we are going to move on to WorldController . Add the following import line
to this class:
import com.packtpub.libgdx.canyonbunny.screens.DirectedGame;
After this, make the following changes to the same class:
private DirectedGame game;
public WorldController (DirectedGame game) {
this.game = game;
init();
}
Finally, remove the line that sets the input processor in init() so that it now
looks like this:
private void init () {
cameraHelper = new CameraHelper();
lives = Constants.LIVES_START;
livesVisual = lives;
timeLeftGameOverDelay = 0;
initLevel();
}
Admittedly, the game code has been subjected to a number of small but important
changes, which has led us to having a generic way of handling any kind of screen
transition. You might want to test run the game so as to verify that screen switching
is still working the same as before.
Implementing the transition effects
Now that we have established a generic way to describe and use screen transitions,
we can now start to implement the transition effects that we want. However, let's
take a quick look at interpolation first as this will greatly improve the overall look
and feel of our transition effects.
Knowing about interpolation algorithms
In Chapter 8 , Special Effects , we have already seen an interpolation algorithm called
Lerp, which stands for Linear Interpolation. As the name implies, it calculates its
interpolated values in an equal stepping from start to end. This works very well for
any kind of constant movement. However, if we want to create more complex effects
such as acceleration, deceleration, or maybe even both in a combination, we will
need to use formulas that express these progressions as nonlinear curves.
 
Search WWH ::




Custom Search