Game Development Reference
In-Depth Information
Creating a slide transition effect
We will now create a slide transition effect that we will use to switch from the game
screen to the menu screen. In this effect, the next screen slides in from the top edge
and moves downwards until it is entirely visible.
The following sequence of screenshots illustrates this effect:
Now, create a new file for the ScreenTransitionSlide class and add the
following code:
package com.packtpub.libgdx.canyonbunny.screens.transitions;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Interpolation;
public class ScreenTransitionSlide implements ScreenTransition {
public static final int LEFT = 1;
public static final int RIGHT = 2;
public static final int UP = 3;
public static final int DOWN = 4;
private static final ScreenTransitionSlide instance =
new ScreenTransitionSlide();
private float duration;
private int direction;
private boolean slideOut;
private Interpolation easing;
public static ScreenTransitionSlide init (float duration,
int direction, boolean slideOut, Interpolation easing) {
 
Search WWH ::




Custom Search