本文整理匯總了Java中com.badlogic.gdx.Files.FileType類的典型用法代碼示例。如果您正苦於以下問題:Java FileType類的具體用法?Java FileType怎麽用?Java FileType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FileType類屬於com.badlogic.gdx.Files包,在下文中一共展示了FileType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public static void main(String[] args) {
AmidakujiMain amidakuji = new AmidakujiMain();
AmidakujiMain.width = 1080;
AmidakujiMain.height = 720;
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "Amidakuji Version 0.4.3";
// cfg.useGL20 = true;
cfg.width = AmidakujiMain.width;
cfg.height = AmidakujiMain.height;
if(System.getProperty("os.name").toLowerCase().indexOf("mac os x") != -1) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Amidakuji");
Application app = Application.getApplication();
app.setDockIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/amidakuji_mac.png")));
} else {
cfg.addIcon("amidakuji.png", FileType.Internal);
cfg.addIcon("amidakuji_lin.png", FileType.Internal);
}
new LwjglApplication(amidakuji, cfg);
}
示例2: writer
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
/** Returns a writer for writing to this file. Parent directories will be created if necessary.
* @param append If false, this file will be overwritten if it exists, otherwise it will be appended.
* @param charset May be null to use the default charset.
* @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or
* {@link FileType#Internal} file, or if it could not be written. */
public Writer writer (boolean append, String charset) {
if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file);
if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file);
parent().mkdirs();
try {
FileOutputStream output = new FileOutputStream(file(), append);
if (charset == null)
return new OutputStreamWriter(output);
else
return new OutputStreamWriter(output, charset);
} catch (IOException ex) {
if (file().isDirectory())
throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex);
}
}
示例3: read
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
/** Returns a stream for reading this file as bytes.
* @throw GdxRuntimeException if the file handle represents a directory, doesn't exist, or could not be read. */
public InputStream read () {
if (type == FileType.Classpath || (type == FileType.Internal && !file.exists())
|| (type == FileType.Local && !file.exists())) {
InputStream input = FileWrapper.class.getResourceAsStream("/" + file.getPath().replace('\\', '/'));
if (input == null) throw new GdxRuntimeException("File not found: " + file + " (" + type + ")");
return input;
}
try {
return new FileInputStream(file());
} catch (Exception ex) {
if (file().isDirectory())
throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
throw new GdxRuntimeException("Error reading file: " + file + " (" + type + ")", ex);
}
}
示例4: writer
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
/** Returns a writer for writing to this file. Parent directories will be created if necessary.
* @param append If false, this file will be overwritten if it exists, otherwise it will be appended.
* @param charset May be null to use the default charset.
* @throw GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or
* {@link FileType#Internal} file, or if it could not be written. */
public Writer writer (boolean append, String charset) {
if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file);
if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file);
parent().mkdirs();
try {
FileOutputStream output = new FileOutputStream(file(), append);
if (charset == null)
return new OutputStreamWriter(output);
else
return new OutputStreamWriter(output, charset);
} catch (IOException ex) {
if (file().isDirectory())
throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex);
}
}
示例5: list
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public FileHandle[] list (FileFilter filter) {
if (type == FileType.Internal) {
try {
String[] relativePaths = assets.list(file.getPath());
FileHandle[] handles = new FileHandle[relativePaths.length];
int count = 0;
for (int i = 0, n = handles.length; i < n; i++) {
String path = relativePaths[i];
FileHandle child = new AndroidFileHandle(assets, new File(file, path), type);
if (!filter.accept(child.file())) continue;
handles[count] = child;
count++;
}
if (count < relativePaths.length) {
FileHandle[] newHandles = new FileHandle[count];
System.arraycopy(handles, 0, newHandles, 0, count);
handles = newHandles;
}
return handles;
} catch (Exception ex) {
throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
}
}
return super.list(filter);
}
示例6: exists
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public boolean exists () {
if (type == FileType.Internal) {
String fileName = file.getPath();
try {
assets.open(fileName).close(); // Check if file exists.
return true;
} catch (Exception ex) {
// This is SUPER slow! but we need it for directories.
try {
return assets.list(fileName).length > 0;
} catch (Exception ignored) {
}
return false;
}
}
return super.exists();
}
示例7: build
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public void build (Array<FileHandle> favorites, FileHandle file) {
sortingPopupMenu.build();
this.file = file;
clearChildren();
addItem(newDirectory);
addItem(sortBy);
addItem(refresh);
addSeparator();
if (file.type() == FileType.Absolute || file.type() == FileType.External) addItem(delete);
if (file.type() == FileType.Absolute) {
addItem(showInExplorer);
if (file.isDirectory()) {
if (favorites.contains(file, false))
addItem(removeFromFavorites);
else
addItem(addToFavorites);
}
}
}
示例8: applicationDidFinishLaunching
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
@Override
public boolean applicationDidFinishLaunching() {
FileUtils.getInstance().addSearchPath("/Users/xujun/remoteProject/Cocos2dJavaImages", FileType.Absolute, true);
FileUtils.getInstance().addSearchPath("Resource", FileType.Internal, true);
Director.getInstance().getOpenGLView().setDesignResolutionSize(1136, 640, ResolutionPolicy.EXACT_FIT);
_testController = TestController.getInstance();
_testController.start();
return true;
}
示例9: create
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
@Override
public void create () {
Array<Controller> controllers = Controllers.getControllers();
if (controllers.size > 0) {
controller = controllers.first();
}
Controllers.addListener(controllerListener);
setScreen(new MainMenu(this));
music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
music.setLooping(true);
music.play();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp (int keycode) {
if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
}
return true;
}
});
fps = new FPSLogger();
}
示例10: newResolver
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
@Override
public FileHandleResolver newResolver (FileType fileType) {
switch (fileType) {
case Absolute:
return new AbsoluteFileHandleResolver();
case Classpath:
return new ClasspathFileHandleResolver();
case External:
return new ExternalFileHandleResolver();
case Internal:
return new InternalFileHandleResolver();
case Local:
return new LocalFileHandleResolver();
}
return null; // Should never happen
}
示例11: ArchiveFileHandle
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public ArchiveFileHandle (FileHandle zipfilehandle, String filePath, boolean init) {
super(filePath, FileType.Classpath);
this.zipfilehandle = zipfilehandle;
if (filePath.startsWith("/"))
filePath = filePath.substring(1);
if (init) {
ZipInputStream stream = new ZipInputStream(zipfilehandle.read());
try {
ZipEntry entry;
while ((entry = stream.getNextEntry()) != null)
if (entry.getName().replace('\\', '/').equals(filePath)) {
entrystream = stream;
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
this.filePath = filePath;
}
示例12: main
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public static void main(String[] arg) {
if (Assets.rebuildAtlas) {
Settings settings = new Settings();
settings.maxWidth = 2048;
settings.maxHeight = 2048;
settings.debug = Assets.drawDebugOutline;
try {
TexturePacker.process(settings, "assets-raw",
"../android/assets", "assets");
} catch (Exception e) {
e.printStackTrace();
}
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 1280;
config.height = 720;
config.addIcon("icon128.png", FileType.Internal);
config.addIcon("icon32.png", FileType.Internal);
config.addIcon("icon16.png", FileType.Internal);
new LwjglApplication(new Main(), config);
}
示例13: start
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
/**
* @throws InitException If a fatal error occurs during initialization.
*/
public void start() throws InitException {
DesktopGdxFileSystem gdxFileSystem = openResourceFileSystem(new File("."));
IWritableFileSystem outputFileSystem = new DesktopOutputFileSystem(FileType.Local, "save/");
final Launcher launcher = new Launcher(gdxFileSystem, outputFileSystem) {
@Override
public void create() {
DesktopGraphicsUtil.setWindowIcon(gdxFileSystem);
windowedSize = DesktopGraphicsUtil.limitInitialWindowSize(Gdx.graphics);
super.create();
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
if (!Gdx.graphics.isFullscreen()) {
windowedSize = Dim.of(width, height);
}
}
@Override
protected void handleInput(INativeInput input) {
super.handleInput(input);
DesktopLauncher.this.handleInput(input);
}
};
NovelPrefsStore prefs = launcher.loadPreferences();
handleCommandlineOptions(prefs);
Lwjgl3ApplicationConfiguration config = createConfig(launcher, prefs);
Lwjgl3Application app = new Lwjgl3Application(launcher, config);
app.addLifecycleListener(new LifecycleListener() {
@Override
public void resume() {
LOG.info("App resume");
}
@Override
public void pause() {
LOG.info("App pause");
}
@Override
public void dispose() {
LOG.info("App dispose");
}
});
}
示例14: main
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
public static void main(String[] arg) throws FileNotFoundException, IOException {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = GameConstants.WINDOW_TITLE;
config.addIcon("gameicon.png", FileType.Internal);
config.width = GameConstants.GAME_WIDTH;
config.height = GameConstants.GAME_HEIGHT;
config.fullscreen = false;
readConfigFromPreference(config);
config.vSyncEnabled = config.fullscreen;
// check debug/run configuration ENVIRONMENT tab
// if the "DEVEOPMENT" flag is true, then the graphics will be packed together
// set the flag to false before exporting the jar
String getenv = System.getenv("DEVELOPMENT");
if (getenv != null && "true".equals(getenv)) {
Settings settings = new Settings();
settings.combineSubdirectories = true;
TexturePacker.process(settings, "../core/assets/graphics/hud", "../core/assets/packedGraphics", "hud");
TexturePacker.process(settings, "../core/assets/graphics/game", "../core/assets/packedGraphics", "gameGraphics");
TexturePacker.process(settings, "../core/assets/graphics/menu", "../core/assets/packedGraphics", "menuGraphics");
}
new LwjglApplication(new GDXGame(), config);
}
示例15: processField
import com.badlogic.gdx.Files.FileType; //導入依賴的package包/類
@Override
public void processField(final Field field, final LmlMacro annotation, final Object component,
final Context context, final ContextInitializer initializer, final ContextDestroyer contextDestroyer) {
try {
final Object macroData = Reflection.getFieldValue(field, component);
final LmlParser parser = interfaceService.get().getParser();
final FileType fileType = annotation.fileType();
if (macroData instanceof String) {
parser.parseTemplate(Gdx.files.getFileHandle((String) macroData, fileType));
} else if (macroData instanceof String[]) {
for (final String macroPath : (String[]) macroData) {
parser.parseTemplate(Gdx.files.getFileHandle(macroPath, fileType));
}
} else {
throw new GdxRuntimeException("Invalid type of LML macro definition in component: " + component
+ ". String or String[] expected, received: " + macroData + ".");
}
} catch (final ReflectionException exception) {
throw new GdxRuntimeException(
"Unable to extract macro paths from field: " + field + " of component: " + component + ".",
exception);
}
}