O'Reilly logo

Learning Libgdx Game Development by Andreas Oehlke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Organizing 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.AssetErrorListener; import com.badlogic.gdx.assets.AssetManager; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required