Game Development Reference
In-Depth Information
The preceding diagram also shows that WorldController and WorldRenderer
are no longer directly used by CanyonBunnyMain . Instead, GameScreen will be
using them from now on as we will move all the game world-specific code from
CanyonBunnyMain to GameScreen .
Create a new file for the AbstractGameScreen class and add the following code:
package com.packtpub.libgdx.canyonbunny.screens;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.assets.AssetManager;
import com.packtpub.libgdx.canyonbunny.game.Assets;
public abstract class AbstractGameScreen implements Screen {
protected Game game;
public AbstractGameScreen (Game game) {
this.game = game;
}
public abstract void render (float deltaTime);
public abstract void resize (int width, int height);
public abstract void show ();
public abstract void hide ();
public abstract void pause ();
public void resume () {
Assets.instance.init(new AssetManager());
}
public void dispose () {
Assets.instance.dispose();
}
}
Each screen will take a reference to the instance of Game . This is necessary because
each screen needs to call the setScreen() method of the Game class. Apart from this,
we have added two lines of code that will make sure that the game's assets will be
correctly loaded and disposed as LibGDX sees fit.
 
Search WWH ::




Custom Search