Organizing the assets
We will now create our own Assets
class to organize and structure our assets. First, add a new constant to the Constants
class that points to the description file of the texture atlas:
public class Constants {
// Visible game world is 5 meters wide
public static final float VIEWPORT_WIDTH = 5.0f;
// Visible game world is 5 meters tall
public static final float VIEWPORT_HEIGHT = 5.0f;
// Location of description file for texture atlas
public static final String TEXTURE_ATLAS_OBJECTS = "images/canyonbunny.pack";
}
Next, create a new file for the Assets
class and add the following code:
package com.packtpub.libgdx.canyonbunny.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.AssetDescriptor; import com.badlogic.gdx.assets.AssetErrorListener; ...
Get Learning LibGDX Game Development - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.