Game Development Reference
In-Depth Information
We will now add the code to automate the generation process of the texture atlas.
Perform the following steps:
1.
Create a new folder called assets-raw under CanyonBunny-desktop . Also,
add a subfolder named assets-raw/images . This is where we put our image
files to be included in the texture atlas.
2.
Next, open the starter class for CanyonBunny-desktop and add the following
two lines of code to import the TexturePacker and its Settings class:
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
import com.badlogic.gdx.tools.texturepacker.TexturePacker.
Settings;
3.
Then, apply the following changes to Main.java in the CanyonBunny-
desktop project:
public class Main {
private static boolean rebuildAtlas = true;
private static boolean drawDebugOutline = true;
public static void main(String[] args) {
if (rebuildAtlas) {
Settings settings = new Settings();
settings.maxWidth = 1024;
settings.maxHeight = 1024;
settings.duplicatePadding = false;
settings.debug = drawDebugOutline;
TexturePacker.process(settings, "assets-
raw/images", "../CanyonBunny-android/assets/images",
"canyonbunny.pack");
}
LwjglApplicationConfiguration cfg = new
LwjglApplicationConfiguration();
cfg.title = "CanyonBunny";
cfg.width = 800;
cfg.height = 480;
new LwjglApplication(new CanyonBunnyMain(), cfg);
}
}
 
Search WWH ::




Custom Search