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();
}
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);
}
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();
}
}
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);
}
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;
}
Aggregations