List of usage examples for com.badlogic.gdx ApplicationListener ApplicationListener
ApplicationListener
From source file:com.cmein.tilemap.utils.TiledMapPacker.java
License:Apache License
public static void main(String[] args) { File tmxFile, baseDir, outputDir; Settings settings = new Settings(); settings.padding = 2;//from w ww . j a v a2s . com settings.duplicatePadding = true; // Create a new JoglApplication so that Gdx stuff works properly new JoglApplication(new ApplicationListener() { @Override public void create() { } @Override public void dispose() { } @Override public void pause() { } @Override public void render() { } @Override public void resize(int width, int height) { } @Override public void resume() { } }, "", 0, 0, false); TiledMapPacker packer = new TiledMapPacker(); /* if (args.length != 3) { System.out.println("Usage: TMXFILE BASEDIR OUTPUTDIR"); return; } */ tmxFile = new File("data/tiledmaps/LEVEL2.tmx"); baseDir = new File("data/"); outputDir = new File("data/"); if (!baseDir.exists()) { throw new RuntimeException("Base directory does not exist"); } if (!tmxFile.exists()) { throw new RuntimeException("TMX file does not exist"); } try { packer.processMap(tmxFile, baseDir, outputDir, settings); } catch (IOException e) { throw new RuntimeException("Error processing map: " + e.getMessage()); } System.exit(0); }
From source file:com.sertaogames.cactus2d.misc.TiledMapPacker.java
License:Apache License
/** Processes a directory of Tile Maps, compressing each tile set contained in any map once. * @param args args[0]: the input directory containing the tmx files (and tile sets, relative to the path listed in the tmx * file). args[1]: The output directory for the tmx files, should be empty before running. WARNING: Use caution if * you have a "../" in the path of your tile sets! The output for these tile sets will be relative to the output * directory. For example, if your output directory is "C:\mydir\output" and you have a tileset with the path * "../tileset.png", the tileset will be output to "C:\mydir\" and the maps will be in "C:\mydir\output". */ public static void main(String[] args) { File tmxFile, inputDir, outputDir; Settings settings = new Settings(); // Note: the settings below are now default... settings.padding = 2;//w w w.j a v a2 s . c o m settings.duplicatePadding = true; // Create a new JoglApplication so that Gdx stuff works properly new JoglApplication(new ApplicationListener() { @Override public void create() { } @Override public void dispose() { } @Override public void pause() { } @Override public void render() { } @Override public void resize(int width, int height) { } @Override public void resume() { } }, "", 0, 0, false); TiledMapPacker packer = new TiledMapPacker(); if (args.length != 2) { System.out.println("Usage: INPUTDIR OUTPUTDIR"); System.exit(0); } inputDir = new File(args[0]); outputDir = new File(args[1]); if (!inputDir.exists()) { throw new RuntimeException("Input directory does not exist"); } try { packer.processMap(inputDir, outputDir, settings); } catch (IOException e) { throw new RuntimeException("Error processing map: " + e.getMessage()); } System.exit(0); }
From source file:com.strategames.catchdastars.tests.desktop.libgdx.junit.GdxTestRunner.java
License:Open Source License
@Override public void run(final RunNotifier notifier) { System.out.println("---------------------------------------------------"); System.out.println(this); System.out.println("Starting run " + getDescription()); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "core-test"; config.width = 504;//from w w w . j av a 2 s . com config.height = 800; config.forceExit = false; final GdxTestRunner runner = this; LwjglApplication app = null; try { Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { runner.finished = true; EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); testNotifier.addFailure(e); } }); /* * Gdx.gl was not getting nulled out between tests. It may not be * the direct cause, but there was no OpenGL context available after * a few runs; null out Gdx.gl and it works again. * * The 'correct' solution here is to use a new classloader for every * test class, but this works for now. */ Gdx.gl = null; System.out.println("Gdx.gl: " + Gdx.gl); System.out.println("Thread in TestRunner: " + Thread.currentThread()); app = new LwjglApplication(new ApplicationListener() { @Override public void resume() { } @Override public void resize(int width, int height) { } @Override public void render() { if (!finished) { System.out.println("Running " + runner.getDescription().getDisplayName()); try { System.out.println("Thread in Render: " + Thread.currentThread()); runner.actualRun(notifier); } catch (Throwable t) { System.out.println("Throwable: " + t.getMessage()); } finally { System.out.println("Finally " + runner.getDescription().getDisplayName()); runner.finished = true; } } } @Override public void pause() { } @Override public void dispose() { System.out.println("Disposing"); } @Override public void create() { AssetManager assetManager = new AssetManager(); Textures textures = Textures.getInstance(); try { textures.addAllToAssetManager(assetManager); } catch (FileNotFoundException e) { e.printStackTrace(); } while (!assetManager.update()) { } ; try { textures.setup(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } }, config); while (!finished) { try { Thread.sleep(100); } catch (InterruptedException e) { System.out.println("Interrupted"); e.printStackTrace(); } } } catch (Throwable t) { System.out.println(t.getMessage()); } finally { if (app != null) { app.stop(); } } System.out.println("Ending run " + getDescription()); }
From source file:de.bitowl.advent.game2.MyTiledMapPacker.java
License:Apache License
/** Processes a directory of Tile Maps, compressing each tile set contained in any map once. * //from w w w . ja v a 2 s . co m * @param args args[0]: the input directory containing the tmx files (and tile sets, relative to the path listed in the tmx * file). args[1]: The output directory for the tmx files, should be empty before running. WARNING: Use caution if * you have a "../" in the path of your tile sets! The output for these tile sets will be relative to the output * directory. For example, if your output directory is "C:\mydir\output" and you have a tileset with the path * "../tileset.png", the tileset will be output to "C:\mydir\" and the maps will be in "C:\mydir\output". args[2]: * --strip-unused (optional, include to let the TiledMapPacker remove tiles which are not used. */ public static void main(String[] args) { final Settings texturePackerSettings = new Settings(); texturePackerSettings.paddingX = 2; texturePackerSettings.paddingY = 2; texturePackerSettings.edgePadding = true; texturePackerSettings.duplicatePadding = true; texturePackerSettings.bleed = true; texturePackerSettings.alias = true; texturePackerSettings.useIndexes = true; final TiledMapPackerSettings packerSettings = new TiledMapPackerSettings(); switch (args.length) { case 3: { inputDir = new File(args[0]); outputDir = new File(args[1]); if ("--strip-unused".equals(args[2])) { packerSettings.stripUnusedTiles = true; } break; } case 2: { inputDir = new File(args[0]); outputDir = new File(args[1]); break; } case 1: { inputDir = new File(args[0]); outputDir = new File(inputDir, "output/"); break; } default: { System.out.println("Usage: INPUTDIR [OUTPUTDIR] [--strip-unused]"); System.exit(0); } } MyTiledMapPacker packer = new MyTiledMapPacker(packerSettings); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.forceExit = false; config.width = 100; config.height = 50; config.useGL20 = true; config.title = "TiledMapPacker"; new LwjglApplication(new ApplicationListener() { @Override public void resume() { } @Override public void resize(int width, int height) { } @Override public void render() { } @Override public void pause() { } @Override public void dispose() { } @Override public void create() { MyTiledMapPacker packer = new MyTiledMapPacker(packerSettings); if (!inputDir.exists()) { throw new RuntimeException("Input directory does not exist"); } try { packer.processMaps(inputDir, outputDir, texturePackerSettings); } catch (IOException e) { throw new RuntimeException("Error processing map: " + e.getMessage()); } Gdx.app.exit(); } }, config); }
From source file:stratos.start.PlayLoop.java
License:Open Source License
public static void setupAndLoop(Playable scenario, String initPackage, Class... initClasses) { PlayLoop.initPackage = initPackage;/* w w w .ja v a 2s . c o m*/ PlayLoop.initClasses = initClasses; PlayLoop.loopChanged = true; PlayLoop.played = scenario; PlayLoop.numStateUpdates = 0; PlayLoop.gameSpeed = 1.0f; if (verbose) { I.say("ASSIGNED NEW PLAYABLE: " + scenario); I.reportStackTrace(); } if (!initDone) { initDone = true; new LwjglApplication(new ApplicationListener() { public void create() { shouldLoop = true; initLoop(); } public void resize(int width, int height) { } public void dispose() { disposeLoop(); } public void pause() { background = true; } public void resume() { background = false; } public void render() { gdxThread = Thread.currentThread(); if (!shouldLoop) { if (verbose) I.say("should not be looping..."); return; } final boolean okay = advanceLoop(); if (!okay) { if (verbose) I.say("Loop does not want to advance!"); exitLoop(); } } }, getConfig()); } }