Search in sources :

Example 51 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class TextureFormatTest method create.

@Override
public void create() {
    FileHandle file = Gdx.files.internal("data/bobargb8888-32x32.png");
    nonMipMapped[0] = new Texture(file, Format.Alpha, false);
    nonMipMapped[1] = new Texture(file, Format.LuminanceAlpha, false);
    nonMipMapped[2] = new Texture(file, Format.RGB888, false);
    nonMipMapped[3] = new Texture(file, Format.RGB565, false);
    nonMipMapped[4] = new Texture(file, Format.RGBA8888, false);
    nonMipMapped[5] = new Texture(file, Format.RGBA4444, false);
    mipMapped[0] = new Texture(file, Format.Alpha, true);
    mipMapped[1] = new Texture(file, Format.LuminanceAlpha, true);
    mipMapped[2] = new Texture(file, Format.RGB888, true);
    mipMapped[3] = new Texture(file, Format.RGB565, true);
    mipMapped[4] = new Texture(file, Format.RGBA8888, true);
    mipMapped[5] = new Texture(file, Format.RGBA4444, true);
    batch = new SpriteBatch();
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 52 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class TiledMapPacker method processSingleMap.

private void processSingleMap(File mapFile, FileHandle dirHandle, Settings texturePackerSettings) throws IOException {
    boolean combineTilesets = this.settings.combineTilesets;
    if (combineTilesets == false) {
        tilesetUsedIds = new HashMap<String, IntArray>();
        tilesetsToPack = new ObjectMap<String, TiledMapTileSet>();
    }
    map = mapLoader.load(mapFile.getCanonicalPath());
    // if enabled, build a list of used tileids for the tileset used by this map
    boolean stripUnusedTiles = this.settings.stripUnusedTiles;
    if (stripUnusedTiles) {
        stripUnusedTiles();
    } else {
        for (TiledMapTileSet tileset : map.getTileSets()) {
            String tilesetName = tileset.getName();
            if (!tilesetsToPack.containsKey(tilesetName)) {
                tilesetsToPack.put(tilesetName, tileset);
            }
        }
    }
    if (combineTilesets == false) {
        FileHandle tmpHandle = new FileHandle(mapFile.getName());
        this.settings.atlasOutputName = tmpHandle.nameWithoutExtension();
        packTilesets(dirHandle, texturePackerSettings);
    }
    FileHandle tmxFile = new FileHandle(mapFile.getCanonicalPath());
    writeUpdatedTMX(map, tmxFile);
}
Also used : IntArray(com.badlogic.gdx.utils.IntArray) TiledMapTileSet(com.badlogic.gdx.maps.tiled.TiledMapTileSet) FileHandle(com.badlogic.gdx.files.FileHandle)

Example 53 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class TiledMapPackerTestRender method render.

@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    viewport.apply();
    mapRenderer.setView(cam);
    mapRenderer.render();
    if (Gdx.input.isKeyPressed(Keys.ESCAPE)) {
        if (DELETE_DELETEME_FOLDER_ON_EXIT) {
            FileHandle deleteMeHandle = Gdx.files.local(MAP_PATH);
            deleteMeHandle.deleteDirectory();
        }
        dispose();
        Gdx.app.exit();
    }
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle)

Example 54 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class TextureUnpacker method main.

public static void main(String[] args) {
    TextureUnpacker unpacker = new TextureUnpacker();
    String atlasFile = null, imageDir = null, outputDir = null;
    // parse the arguments and display the help text if there is a problem with the command line arguments
    switch(unpacker.parseArguments(args)) {
        case 0:
            System.out.println(HELP);
            return;
        case 3:
            outputDir = args[2];
        case 2:
            imageDir = args[1];
        case 1:
            atlasFile = args[0];
    }
    File atlasFileHandle = new File(atlasFile);
    String atlasParentPath = atlasFileHandle.getParentFile().getAbsolutePath();
    // Set the directory variables to a default when they weren't given in the variables
    if (imageDir == null)
        imageDir = atlasParentPath;
    if (outputDir == null)
        outputDir = (new File(atlasParentPath, DEFAULT_OUTPUT_PATH)).getAbsolutePath();
    // Opens the atlas file from the specified filename
    TextureAtlasData atlas = new TextureAtlasData(new FileHandle(atlasFile), new FileHandle(imageDir), false);
    unpacker.splitAtlas(atlas, outputDir);
}
Also used : TextureAtlasData(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData) FileHandle(com.badlogic.gdx.files.FileHandle) File(java.io.File)

Example 55 with FileHandle

use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.

the class BitmapFontLoader method getDependencies.

@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, BitmapFontParameter parameter) {
    Array<AssetDescriptor> deps = new Array();
    if (parameter != null && parameter.bitmapFontData != null) {
        data = parameter.bitmapFontData;
        return deps;
    }
    data = new BitmapFontData(file, parameter != null ? parameter.flip : false);
    if (parameter != null && parameter.atlasName != null) {
        deps.add(new AssetDescriptor(parameter.atlasName, TextureAtlas.class));
    } else {
        for (int i = 0; i < data.getImagePaths().length; i++) {
            String path = data.getImagePath(i);
            FileHandle resolved = resolve(path);
            TextureLoader.TextureParameter textureParams = new TextureLoader.TextureParameter();
            if (parameter != null) {
                textureParams.genMipMaps = parameter.genMipMaps;
                textureParams.minFilter = parameter.minFilter;
                textureParams.magFilter = parameter.magFilter;
            }
            AssetDescriptor descriptor = new AssetDescriptor(resolved, Texture.class, textureParams);
            deps.add(descriptor);
        }
    }
    return deps;
}
Also used : Array(com.badlogic.gdx.utils.Array) BitmapFontData(com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData) FileHandle(com.badlogic.gdx.files.FileHandle) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Aggregations

FileHandle (com.badlogic.gdx.files.FileHandle)79 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)23 IOException (java.io.IOException)22 Array (com.badlogic.gdx.utils.Array)18 File (java.io.File)18 Element (com.badlogic.gdx.utils.XmlReader.Element)9 Texture (com.badlogic.gdx.graphics.Texture)8 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)7 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)7 IntArray (com.badlogic.gdx.utils.IntArray)7 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)6 AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)5 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)4 TextureAtlasData (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData)4 Json (com.badlogic.gdx.utils.Json)4 GwtFileHandle (com.badlogic.gdx.backends.gwt.GwtFileHandle)3 Color (com.badlogic.gdx.graphics.Color)3 InputStream (java.io.InputStream)3 OutputStream (java.io.OutputStream)3 Writer (java.io.Writer)3