We are now ready to test our Assets
class with the rest of the already built game code.
We need to add the following two imports to CanyonBunnyMain
:
import com.badlogic.gdx.assets.AssetManager; import com.packtpub.libgdx.canyonbunny.game.Assets;
After this, we add the calls to load, reload, and unload our assets with the following changes to the code:
@Override public void create () { // Set Libgdx log level to DEBUG Gdx.app.setLogLevel(Application.LOG_DEBUG); // Load assets Assets.instance.init(new AssetManager()); // Initialize controller and renderer worldController = new WorldController(); worldRenderer = new WorldRenderer(worldController); } @Override public void resume () { Assets.instance.init(new AssetManager()); paused = false; } @Override public void dispose () { worldRenderer.dispose(); Assets.instance.dispose(); }
In create()
, we instantiate a new AssetManager
object and pass it to the init()
method of our Assets
class. Note that...