Java Code Examples for com.badlogic.gdx.tools.texturepacker.TexturePacker#process()

The following examples show how to use com.badlogic.gdx.tools.texturepacker.TexturePacker#process() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopLauncher.java    From FruitCatcher with Apache License 2.0 6 votes vote down vote up
public static void main (String[] arg) {
       // Create two run configurations
       // 1. For texture packing. Pass 'texturepacker' as argument and use desktop/src
       //    as working directory
       // 2. For playing game with android/assets as working directory
       if (arg.length == 1 && arg[0].equals("texturepacker")) {
           String outdir = "assets";
           TexturePacker.Settings settings = new TexturePacker.Settings();
           settings.maxWidth = 1024;
           settings.maxHeight = 1024;
           TexturePacker.process(settings, "images", outdir, "game");
           TexturePacker.process(settings, "text-images", outdir, "text_images");
           TexturePacker.process(settings, "text-images-de", outdir, "text_images_de");
       }
       else {
           LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
           config.title = "FruitCatcher";
           config.width = 800;
           config.height = 480;
           new LwjglApplication(new FruitCatcherGame(null, "en"), config);
       }
}
 
Example 2
Source File: WelcomeScreen.java    From gdx-skineditor with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param projectName
 */
public void createProject(String projectName) {

	FileHandle projectFolder = Gdx.files.local("projects").child(projectName);
	if (projectFolder.exists() == true) {
		game.showNotice("Error", "Project name already in use!", stage);
		return;
	}

	projectFolder.mkdirs();
	projectFolder.child("assets").mkdirs();
	projectFolder.child("backups").mkdirs();
	game.skin.save(projectFolder.child("uiskin.json"));

	// Copy assets
	FileHandle assetsFolder = Gdx.files.local("resources/raw");
	assetsFolder.copyTo(projectFolder.child("assets"));
	// Rebuild from raw resources
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	TexturePacker.process(settings, "projects/" + projectName +"/assets/", "projects/" + projectName, "uiskin");

	game.showNotice("Operation completed", "New project successfully created.", stage);
	
	refreshProjects();
}
 
Example 3
Source File: MainScreen.java    From gdx-skineditor with Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
public void refreshResources() {
	
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	settings.maxWidth = 2048;
	settings.maxHeight = 2048;
	TexturePacker.process(settings, "projects/" + currentProject +"/assets/", "projects/" + currentProject, "uiskin");
	

	// Load project skin
	if (game.skinProject != null) {
		game.skinProject.dispose();
	}
	
	game.skinProject = new Skin();
	game.skinProject.addRegions(new TextureAtlas(Gdx.files.local("projects/" + currentProject +"/uiskin.atlas")));
	game.skinProject.load(Gdx.files.local("projects/" + currentProject +"/uiskin.json"));

	
}
 
Example 4
Source File: Generator.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
        TexturePacker.Settings settings = new TexturePacker.Settings();
        settings.combineSubdirectories = true;
        TexturePacker.process(settings, "generator/gfx", "android/assets", "gfx");
        TexturePacker.process(settings, "generator/world-map", "android/assets", "world-map");
//        renamePrefixes("generator/gfx/ui/level-icon", "ui-level-icon-", "");
    }
 
Example 5
Source File: TexturePackerApp.java    From ninja-rabbit with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) {
	Settings settings = new Settings();
	settings.edgePadding = true;
	settings.paddingX = 2;
	settings.paddingY = 2;
	settings.pot = false;
	settings.maxHeight = 2048;
	settings.maxWidth = 2048;
	TexturePacker.process(settings, "C:\\Users\\Nicolás\\Desktop\\tiles",
			"C:\\Users\\Nicolás\\Desktop\\tiles.pack",
			"tiles.pack");
}
 
Example 6
Source File: SkinEditorGame.java    From gdx-skineditor with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	opt = new OptionalChecker();
	
	fm = new SystemFonts();
	fm.refreshFonts();
	
	// Create projects folder if not already here
	FileHandle dirProjects = new FileHandle("projects");
	
	if (dirProjects.isDirectory() == false) {
		dirProjects.mkdirs();
	}
	
	// Rebuild from raw resources, kind of overkill, might disable it for production
	TexturePacker.Settings settings = new TexturePacker.Settings();
	settings.combineSubdirectories = true;
	TexturePacker.process(settings, "resources/raw/", ".", "resources/uiskin");

	batch = new SpriteBatch();
	skin = new Skin();
	atlas = new TextureAtlas(Gdx.files.internal("resources/uiskin.atlas"));
	
	
	skin.addRegions(new TextureAtlas(Gdx.files.local("resources/uiskin.atlas")));
	skin.load(Gdx.files.local("resources/uiskin.json"));
	
	screenMain = new MainScreen(this);
	screenWelcome = new WelcomeScreen(this);
	setScreen(screenWelcome);
	
}
 
Example 7
Source File: TextureSetup.java    From SIFTrain with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    TexturePacker.Settings config = new TexturePacker.Settings();
    config.maxWidth = 512;
    config.maxHeight = 512;
    TexturePacker.process(config, "images/", "textures/", "textures.pack");
}
 
Example 8
Source File: ImageUtils.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public static void createAtlas(String inDir, String outdir, String name, float scale, int maxWidth, int maxHeight,
		TextureFilter filterMin, TextureFilter filterMag, String outputFormat, boolean stripWhiteSpace)
		throws IOException {
	Settings settings = new Settings();

	settings.pot = false;
	settings.paddingX = 2;
	settings.paddingY = 2;
	settings.duplicatePadding = false;
	settings.edgePadding = true;
	settings.rotation = false;
	settings.minWidth = 16;
	settings.minWidth = 16;
	settings.stripWhitespaceX = stripWhiteSpace;
	settings.stripWhitespaceY = stripWhiteSpace;
	settings.alphaThreshold = 0;

	settings.filterMin = filterMin;
	settings.filterMag = filterMag;
	settings.wrapX = Texture.TextureWrap.ClampToEdge;
	settings.wrapY = Texture.TextureWrap.ClampToEdge;
	settings.format = Format.RGBA8888;
	settings.alias = true;
	settings.outputFormat = outputFormat;
	settings.jpegQuality = 0.9f;
	settings.ignoreBlankImages = true;
	settings.fast = false;
	settings.debug = false;

	settings.maxWidth = maxWidth;
	settings.maxHeight = maxHeight;

	EditorLogger.debug("ATLAS MAXWIDTH: " + settings.maxWidth);

	File inTmpDir = new File(inDir);

	// Resize images to create atlas for different resolutions
	if (scale != 1.0f) {
		inTmpDir = DesktopUtils.createTempDirectory();

		ImageUtils.scaleDirFiles(new File(inDir), inTmpDir, scale);
	}

	TexturePacker.process(settings, inTmpDir.getAbsolutePath(), outdir,
			name.endsWith(".atlas") ? name : name + ".atlas");

	if (scale != 1.0f) {
		DesktopUtils.removeDir(inTmpDir.getAbsolutePath());
	}
}
 
Example 9
Source File: TextureRegionTestTextures.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
public static void main(String [] args) {
	TexturePacker.process("../uats/texture-pack", "../uats/src/main/resources", TextureRegionUAT.TEXTURE_PACK);
}
 
Example 10
Source File: NinePatchEditorDialog.java    From gdx-skineditor with Apache License 2.0 2 votes vote down vote up
public void refreshPreview() {

		Gdx.app.log("NinePatchEditorDialog","refresh preview.");

		Pixmap pixmapImage = new Pixmap(Gdx.files.internal(textSourceImage.getText()));
		
		Pixmap pixmap = new Pixmap((int) (pixmapImage.getWidth()+2), (int) (pixmapImage.getHeight()+2), Pixmap.Format.RGBA8888);
		pixmap.drawPixmap(pixmapImage,1,1);

		pixmap.setColor(Color.BLACK);
		
		// Range left
		int h = pixmapImage.getHeight()+1;
		pixmap.drawLine(0, (int) (h * rangeLeft.rangeStart),0, (int) (h * rangeLeft.rangeStop));
		

		// Range top
		int w = pixmapImage.getWidth()+1;
		pixmap.drawLine((int) (w * rangeTop.rangeStart), 0,(int) (w * rangeTop.rangeStop), 0);

		// Range right
		h = pixmapImage.getHeight()+1;
		pixmap.drawLine(pixmapImage.getWidth()+1, (int) (h * rangeRight.rangeStart),pixmapImage.getWidth()+1, (int) (h * rangeRight.rangeStop));

		// Range bottom
		w = pixmapImage.getWidth()+1;
		pixmap.drawLine((int) (w * rangeBottom.rangeStart), pixmap.getHeight()-1,(int) (w * rangeBottom.rangeStop), pixmap.getHeight()-1);
		
		
		PixmapIO.writePNG(tmpFile, pixmap);
		
		pixmapImage.dispose();
		pixmap.dispose();

		FileHandle fh = new FileHandle(System.getProperty("java.io.tmpdir")).child("skin_ninepatch");
		TexturePacker.Settings settings = new TexturePacker.Settings();
		TexturePacker.process(settings, fh.path(), fh.path(), "pack");

		TextureAtlas ta = new TextureAtlas(fh.child("pack.atlas"));
		NinePatch np = ta.createPatch("button");
		NinePatchDrawable drawable = new NinePatchDrawable(np);
		reviewTablePreview();	
		buttonPreview1.getStyle().up = drawable;
		

	}