本文整理汇总了Java中com.badlogic.gdx.files.FileHandle.child方法的典型用法代码示例。如果您正苦于以下问题:Java FileHandle.child方法的具体用法?Java FileHandle.child怎么用?Java FileHandle.child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.files.FileHandle
的用法示例。
在下文中一共展示了FileHandle.child方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToDex
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
private FileHandle convertToDex(FileHandle fileHandle) throws Exception {
String inputHash = hashFile(fileHandle);
FileHandle cacheDir = new FileHandle(androidCompatibility.androidLauncher.getCacheDir());
FileHandle dexDir = cacheDir.child("converted_mod_dex");
dexDir.mkdirs();
FileHandle dexFile = dexDir.child(inputHash + ".dex");
if (!dexFile.exists()) {
Log.warning("Trying to convert jar to dex: " + fileHandle.file().getAbsolutePath());
com.android.dx.command.dexer.Main.Arguments arguments = new com.android.dx.command.dexer.Main.Arguments();
arguments.parse(new String[]{"--output=" + dexFile.file().getAbsolutePath(), fileHandle.file().getAbsolutePath()});
int result = com.android.dx.command.dexer.Main.run(arguments);
if (result != 0) throw new CubesException("Failed to convert jar to dex [" + result + "]: " + fileHandle.file().getAbsolutePath());
Log.warning("Converted jar to dex: " + fileHandle.file().getAbsolutePath());
}
return dexFile;
}
示例2: readPlayer
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public Player readPlayer(UUID uuid, ClientIdentifier clientIdentifier) {
if (fileHandle == null)
return null;
FileHandle folder = folderPlayer();
FileHandle file = folder.child(uuid.toString());
if (!file.exists())
return null;
try {
DataGroup data = (DataGroup) Data.input(file.file());
Player player = new Player(data.getString("username"), uuid, clientIdentifier);
player.read(data);
return player;
} catch (Exception e) {
Log.warning("Failed to read player", e);
return null;
}
}
示例3: readCave
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public Cave readCave(AreaReference areaReference) {
if (fileHandle == null)
return null;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
if (!file.exists())
return null;
try {
InputStream read = file.read();
DataInputStream dataInputStream = new DataInputStream(read);
Cave cave = Cave.read(dataInputStream);
read.close();
return cave;
} catch (IOException e) {
Log.warning("Failed to read cave", e);
return null;
}
}
示例4: createSave
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static Save createSave(String name, String generatorID, Gamemode gamemode, String seedString) {
if (name != null) name = name.trim();
if (name == null || name.isEmpty()) name = "world-" + Integer.toHexString(MathUtils.random.nextInt());
FileHandle folder = getSavesFolder();
FileHandle handle = folder.child(name);
handle.mkdirs();
Compatibility.get().nomedia(handle);
Save s = new Save(name, handle);
SaveOptions options = new SaveOptions();
options.setWorldSeed(seedString);
options.worldType = generatorID;
options.worldGamemode = gamemode;
s.setSaveOptions(options);
return s;
}
示例5: takeScreenshot
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static void takeScreenshot() {
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight());
FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
dir.mkdirs();
FileHandle f = dir.child(System.currentTimeMillis() + ".png");
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
try {
writer.setFlipY(true);
writer.write(f, pixmap);
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new CubesException("Error writing PNG: " + f, ex);
} finally {
pixmap.dispose();
}
Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
示例6: takeScreenshot
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static void takeScreenshot() {
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
dir.mkdirs();
FileHandle f = dir.child(System.currentTimeMillis() + ".png");
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
try {
writer.setFlipY(true);
writer.write(f, pixmap);
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new CubesException("Error writing PNG: " + f, ex);
} finally {
pixmap.dispose();
}
Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
示例7: readCave
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public Cave readCave(AreaReference areaReference) {
if (fileHandle == null) return null;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
if (!file.exists()) return null;
try {
InputStream read = file.read();
DataInputStream dataInputStream = new DataInputStream(read);
Cave cave = Cave.read(dataInputStream);
read.close();
return cave;
} catch (IOException e) {
Log.warning("Failed to read cave", e);
return null;
}
}
示例8: getBaseFolder
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
@Override
public FileHandle getBaseFolder() {
FileHandle fileHandle = getWorkingFolder();
if (Branding.IS_DEBUG) {
fileHandle = fileHandle.child("server");
}
return fileHandle;
}
示例9: getBaseFolder
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public FileHandle getBaseFolder() {
if (Adapter.isDedicatedServer()) return getWorkingFolder();
FileHandle homeDir = Gdx.files.absolute(System.getProperty("user.home"));
switch (os) {
case Windows:
return Gdx.files.absolute(System.getenv("APPDATA")).child(Branding.NAME);
case Mac:
return homeDir.child("Library").child("Application Support").child(Branding.NAME);
default:
return homeDir.child("." + Branding.NAME);
}
}
示例10: file
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static FileHandle file(Save save, int x, int z) {
FileHandle folderArea = save.folderArea();
FileHandle xMostSignificant = folderArea.child(Integer.toString(x & 0xFFFF0000));
FileHandle xLeastSignificant = xMostSignificant.child(Integer.toString(x & 0xFFFF));
FileHandle zMostSignificant = xLeastSignificant.child(Integer.toString(z & 0xFFFF0000));
zMostSignificant.mkdirs();
Compatibility.get().nomedia(zMostSignificant);
return zMostSignificant.child(Integer.toString(z & 0xFFFF));
}
示例11: writePlayer
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public void writePlayer(Player player) {
if (readOnly)
return;
FileHandle folder = folderPlayer();
FileHandle file = folder.child(player.uuid.toString());
DataGroup data = player.write();
try {
Data.output(data, file.file());
} catch (Exception e) {
Log.warning("Failed to write player", e);
}
}
示例12: writeCave
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public void writeCave(AreaReference areaReference, Cave cave) {
if (readOnly)
return;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
try {
OutputStream write = file.write(false);
DataOutputStream dataOutputStream = new DataOutputStream(write);
cave.write(dataOutputStream);
write.close();
} catch (IOException e) {
Log.warning("Failed to write cave", e);
}
}
示例13: getPackedTextureSheet
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
private static PackedTextureSheet getPackedTextureSheet(AssetType... assetType) {
if (Adapter.isDedicatedServer())
return null;
TexturePacker texturePacker = new TexturePacker(2048, 2048, 1, true);
Pixmap pixmap;
getPacketTextureSheetFor(assetType, texturePacker, pixmap);
FileHandle fileHandle = assetsFolder.child("packed");
fileHandle.mkdirs();
Compatibility.get().nomedia(fileHandle);
fileHandle = fileHandle.child(assetType[0].name() + ".cim");
try {
PixmapIO.writeCIM(fileHandle, texturePacker.getPixmap());
} catch (GdxRuntimeException e) {
Log.error("Failed to write packed image", e);
}
Texture texture = new Texture(fileHandle);
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
PackedTextureSheet packedTextureSheet = new PackedTextureSheet(
new Material(TextureAttribute.createDiffuse(texture)));
packedTextureSheet.getMaterial().set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
Map<Asset, TexturePacker.PackRectangle> rectangles = texturePacker.getRectangles();
int num = 0;
for (Map.Entry<Asset, TexturePacker.PackRectangle> entry : rectangles.entrySet()) {
num++;
TextureRegion textureRegion = new TextureRegion(texture, entry.getValue().x, entry.getValue().y,
entry.getValue().width, entry.getValue().height);
entry.getKey().setPackedTextureRegion(textureRegion, packedTextureSheet);
packedTextureSheet.getPackedTextures().put(entry.getKey().toString(), textureRegion);
}
for (AssetType type : assetType) {
type.setPackedTextureSheet(packedTextureSheet);
}
return packedTextureSheet;
}
示例14: file
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public static FileHandle file(Save save, int x, int z) {
FileHandle folderArea = save.folderArea();
FileHandle xMostSignificant = folderArea.child(Integer.toString(x & 0xFFFF0000));
FileHandle xLeastSignificant = xMostSignificant.child(Integer.toString(x & 0xFFFF));
FileHandle zMostSignificant = xLeastSignificant.child(Integer.toString(z & 0xFFFF0000));
zMostSignificant.mkdirs();
Compatibility.get().nomedia(zMostSignificant);
return zMostSignificant.child(Integer.toString(z & 0xFFFF));
}
示例15: writePlayer
import com.badlogic.gdx.files.FileHandle; //导入方法依赖的package包/类
public void writePlayer(Player player) {
if (readOnly) return;
FileHandle folder = folderPlayer();
FileHandle file = folder.child(player.uuid.toString());
DataGroup data = player.write();
try {
Data.output(data, file.file());
} catch (Exception e) {
Log.warning("Failed to write player", e);
}
}