SHARE
TWEET
Untitled
a guest
Nov 18th, 2016
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- package com.boringville.td.tdtest04.core.tools;
- import java.io.File;
- import java.io.IOException;
- import java.nio.file.Files;
- import java.nio.file.StandardCopyOption;
- import com.badlogic.gdx.graphics.Texture.TextureFilter;
- import com.badlogic.gdx.tools.imagepacker.TexturePacker2;
- import com.badlogic.gdx.tools.imagepacker.TexturePacker2.Settings;
- public class TexturePacker {
- private static void delete(final File delete) {
- if (delete.isDirectory()) {
- for (final File file : delete.listFiles()) {
- delete(file);
- }
- }
- delete.delete();
- }
- public static void main(final String[] args) throws Exception {
- final Settings settings = new Settings();
- settings.maxWidth = 1024;
- settings.maxHeight = 1024;
- settings.pot = true;
- settings.forceSquareOutput = true;
- settings.filterMin = TextureFilter.MipMapLinearLinear;
- settings.filterMag = TextureFilter.Linear;
- TexturePacker2.process(settings, "../assets-raw/mobs", "../assets/gfx", "mobs");
- TexturePacker2.process("../assets-raw/ui", "../assets/ui", "ui");
- settings.edgePadding = true;
- settings.paddingX = 2;
- settings.paddingY = 2;
- settings.duplicatePadding = true;
- packMap(settings, "../../../", "grasslands", "../assets/gfx/maps/", 32);
- packMap(settings, "../../../", "grasslands", "../assets/gfx/maps/", 48);
- packMap(settings, "../../../", "grasslands", "../assets/gfx/maps/", 64);
- packMap(settings, "../../../", "grasslands", "../assets/gfx/maps/", 96);
- }
- private static void packMap(final Settings settings, final String root, final String in,
- final String out, final int resolution) throws Exception {
- final String inPath = root + "/" + in + "/pieces/";
- sort(inPath, "" + resolution);
- TexturePacker2.process(settings, inPath + resolution, out + "/" + in + "/" + resolution,
- "grasslands");
- }
- private static void sort(final String root, final String resolution) throws IOException {
- final File outDir = new File(root + "/" + resolution);
- delete(outDir);
- outDir.mkdirs();
- for (final File file : new File(root).listFiles()) {
- if (file.getName().endsWith("-" + resolution + ".png")) {
- Files.copy(file.toPath(),
- new File(outDir, file.getName().replace("-" + resolution, "")).toPath(),
- StandardCopyOption.REPLACE_EXISTING);
- }
- }
- }
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

