List of usage examples for com.badlogic.gdx.files FileHandle readString
public String readString()
From source file:app.badlogicgames.superjumper.Assets.java
License:Apache License
public static void load() { background = loadTexture(prefix + "background.png"); backgroundRegion = new TextureRegion(background, 0, 0, 320, 480); items = loadTexture(prefix + "items.png"); multiplayer = loadTexture(prefix + "multiplayer.png"); // DATest// w ww . jav a2 s.c o m // enemyBob = loadTexture(prefix + "monster2.png"); enemyBob1 = loadTexture(prefix + "monster2.png"); enemyBob2 = loadTexture(prefix + "monster3.png"); mainMenu = new TextureRegion(items, 0, 224, 300, 110); pauseMenu = new TextureRegion(items, 224, 128, 192, 96); ready = new TextureRegion(items, 320, 224, 192, 32); gameOver = new TextureRegion(items, 352, 256, 160, 96); highScoresRegion = new TextureRegion(Assets.items, 0, 257, 300, 110 / 3); logo = new TextureRegion(items, 0, 352, 274, 142); soundOff = new TextureRegion(items, 0, 0, 64, 64); soundOn = new TextureRegion(items, 64, 0, 64, 64); arrow = new TextureRegion(items, 0, 64, 64, 64); pause = new TextureRegion(items, 64, 64, 64, 64); spring = new TextureRegion(items, 128, 0, 32, 32); castle = new TextureRegion(items, 128, 64, 64, 64); coinAnim = new Animation(0.2f, new TextureRegion(items, 128, 32, 32, 32), new TextureRegion(items, 160, 32, 32, 32), new TextureRegion(items, 192, 32, 32, 32), new TextureRegion(items, 160, 32, 32, 32)); bobJump = new Animation(0.2f, new TextureRegion(items, 0, 128, 32, 32), new TextureRegion(items, 32, 128, 32, 32)); bobFall = new Animation(0.2f, new TextureRegion(items, 64, 128, 32, 32), new TextureRegion(items, 96, 128, 32, 32)); bobHit = new TextureRegion(items, 128, 128, 32, 32); squirrelFly = new Animation(0.2f, new TextureRegion(items, 0, 160, 32, 32), new TextureRegion(items, 32, 160, 32, 32)); platform = new TextureRegion(items, 64, 160, 64, 16); brakingPlatform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16), new TextureRegion(items, 64, 176, 64, 16), new TextureRegion(items, 64, 192, 64, 16), new TextureRegion(items, 64, 208, 64, 16)); font = new BitmapFont(Gdx.files.internal(prefix + "font.fnt"), Gdx.files.internal(prefix + "font.png"), false); music = Gdx.audio.newMusic(Gdx.files.internal(prefix + "music.mp3")); music.setLooping(true); music.setVolume(0.5f); if (Settings.soundEnabled) music.play(); jumpSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "jump.wav")); highJumpSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "highjump.wav")); hitSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "hit.wav")); coinSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "coin.wav")); clickSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "click.wav")); FileHandle file = Gdx.files.internal(prefix + "platform.data"); platformDataString = file.readString(); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.physicEditor.BodyEditorLoader.java
License:Open Source License
public BodyEditorLoader(FileHandle file) { if (file == null) throw new NullPointerException("file is null"); model = readJson(file.readString()); }
From source file:br.unb.unbomber.Settings.java
License:Apache License
public static void load() { try {/*from ww w. java 2s.c o m*/ FileHandle filehandle = Gdx.files.external(file); String[] strings = filehandle.readString().split("\n"); soundEnabled = Boolean.parseBoolean(strings[0]); for (int i = 0; i < 5; i++) { highscores[i] = Integer.parseInt(strings[i + 1]); } } catch (Throwable e) { // :( It's ok we have defaults } }
From source file:CB_Translation_Base.TranslationEngine.Translation.java
License:Open Source License
private String getLangNameFromFile(String FilePath) throws IOException { FileHandle lang = Gdx.files.getFileHandle(FilePath, mFiletype); String langRead = lang.readString(); int pos1 = langRead.indexOf("lang=") + 5; int pos2 = langRead.indexOf(BR, pos1); String Value = langRead.substring(pos1, pos2); return Value; }
From source file:CB_Translation_Base.TranslationEngine.Translation.java
License:Open Source License
private String getTextFile(String Name, String overrideLangId) throws IOException { String FilePath = "data/string_files/" + Name + "." + overrideLangId + ".txt"; FileHandle file = Gdx.files.getFileHandle(FilePath, FileType.Internal); String text = file.readString(); return text;/*from www. j a v a 2 s .c o m*/ }
From source file:com.ads.puzzle.fifa.Settings.java
License:Apache License
public static void load() { try {/* w w w . ja v a 2 s.co m*/ Answer.gateStars.add(0); FileHandle filehandle = Gdx.files.external(file); String[] strings = filehandle.readString().split("\n"); soundEnabled = Boolean.parseBoolean(strings[0]); for (int i = 0; i < 5; i++) { highscores[i] = Integer.parseInt(strings[i + 1]); } } catch (Throwable e) { // :( It's ok we have defaults } }
From source file:com.altportalgames.colorrain.utils.TiledMapHelper.java
License:Apache License
/** * Reads a file describing the collision boundaries that should be set * per-tile and adds static bodies to the boxd world. * /*from w w w . jav a2s . com*/ * @param collisionsFile * @param world * @param pixelsPerMeter * the pixels per meter scale used for this world */ public void loadCollisions(String collisionsFile, World world, float pixelsPerMeter) { System.out.println("tilewidth " + getMap().height); /** * Detect the tiles and dynamically create a representation of the map * layout, for collision detection. Each tile has its own collision * rules stored in an associated file. * * The file contains lines in this format (one line per type of tile): * tileNumber XxY,XxY XxY,XxY * * Ex: * * 3 0x0,31x0 ... 4 0x0,29x0 29x0,29x31 * * For a 32x32 tileset, the above describes one line segment for tile #3 * and two for tile #4. Tile #3 has a line segment across the top. Tile * #1 has a line segment across most of the top and a line segment from * the top to the bottom, 30 pixels in. */ FileHandle fh = Gdx.files.internal(collisionsFile); String collisionFile = fh.readString(); String lines[] = collisionFile.split("\\r?\\n"); HashMap<Integer, ArrayList<LineSegment>> tileCollisionJoints = new HashMap<Integer, ArrayList<LineSegment>>(); /** * Some locations on the map (perhaps most locations) are "undefined", * empty space, and will have the tile type 0. This code adds an empty * list of line segments for this "default" tile. */ tileCollisionJoints.put(Integer.valueOf(0), new ArrayList<LineSegment>()); for (int n = 0; n < lines.length; n++) { String cols[] = lines[n].split(" "); int tileNo = Integer.parseInt(cols[0]); ArrayList<LineSegment> tmp = new ArrayList<LineSegment>(); for (int m = 1; m < cols.length; m++) { String coords[] = cols[m].split(","); String start[] = coords[0].split("x"); String end[] = coords[1].split("x"); tmp.add(new LineSegment(Integer.parseInt(start[0]), Integer.parseInt(start[1]), Integer.parseInt(end[0]), Integer.parseInt(end[1]))); } tileCollisionJoints.put(Integer.valueOf(tileNo), tmp); } ArrayList<LineSegment> collisionLineSegments = new ArrayList<LineSegment>(); for (int y = 0; y < getMap().height; y++) { for (int x = 0; x < getMap().width; x++) { int tileType = getMap().layers.get(1).tiles[(getMap().height - 1) - y][x]; for (int n = 0; n < tileCollisionJoints.get(Integer.valueOf(tileType)).size(); n++) { LineSegment lineSeg = tileCollisionJoints.get(Integer.valueOf(tileType)).get(n); addOrExtendCollisionLineSegment(x * Assets.tileWidth + lineSeg.start().x, y * Assets.tileHeight - lineSeg.start().y + Assets.tileHeight, x * Assets.tileWidth + lineSeg.end().x, y * Assets.tileHeight - lineSeg.end().y + Assets.tileHeight, collisionLineSegments); } } } BodyDef groundBodyDef = new BodyDef(); groundBodyDef.type = BodyDef.BodyType.StaticBody; groundBody = world.createBody(groundBodyDef); for (LineSegment lineSegment : collisionLineSegments) { PolygonShape environmentShape = new PolygonShape(); environmentShape.setAsEdge(lineSegment.start().mul(1 / Assets.PIXELS_PER_METER_X), lineSegment.end().mul(1 / Assets.PIXELS_PER_METER_X)); groundBody.createFixture(environmentShape, 0); environmentShape.dispose(); } /** * Drawing a boundary around the entire map. We can't use a box because * then the world objects would be inside and the physics engine would * try to push them out. */ PolygonShape mapBounds = new PolygonShape(); mapBounds.setAsEdge(new Vector2(0.0f, 0.0f), new Vector2(getWidth() / Assets.PIXELS_PER_METER_X, 0.0f)); groundBody.createFixture(mapBounds, 0); mapBounds.setAsEdge(new Vector2(0.0f, getHeight() / Assets.PIXELS_PER_METER_Y), new Vector2(getWidth() / Assets.PIXELS_PER_METER_X, getHeight() / Assets.PIXELS_PER_METER_Y)); groundBody.createFixture(mapBounds, 0); mapBounds.setAsEdge(new Vector2(0.0f, 0.0f), new Vector2(0.0f, getHeight() / Assets.PIXELS_PER_METER_Y)); groundBody.createFixture(mapBounds, 0); mapBounds.setAsEdge(new Vector2(getWidth() / Assets.PIXELS_PER_METER_X, 0.0f), new Vector2(getWidth() / Assets.PIXELS_PER_METER_X, getHeight() / Assets.PIXELS_PER_METER_Y)); groundBody.createFixture(mapBounds, 0); mapBounds.dispose(); }
From source file:com.andgate.ikou.io.LevelLoader.java
License:Open Source License
public static Level loadOld(LevelData levelData) { Floor[] floors = new Floor[levelData.totalFloors + 1]; for (int floorIndex = 0; floorIndex < floors.length - 1; floorIndex++) { String floorFilePath = levelData.getFloorPath(floorIndex + 1); FileHandle floorFile = Gdx.files.internal(floorFilePath); floors[floorIndex] = (TileFloorParser.parse(floorFile.readString())); }// w w w . ja v a 2s . co m int lastFloorIndex = floors.length - 1; floors[lastFloorIndex] = buildVictoryFloor(); return new Level(floors, levelData.name); }
From source file:com.andgate.ikou.io.ProgressDatabaseService.java
License:Open Source License
public static ProgressDatabase read() { FileHandle saveFile = Gdx.files.external(Constants.PROGRESS_DATABASE_EXTERNAL_PATH); if (saveFile.exists()) { String jsonString;/*from ww w . ja v a 2s. c o m*/ try { jsonString = Base64Coder.decodeString(saveFile.readString()); } catch (java.lang.IllegalArgumentException e) { // The highscore has been tampered with, // so now they get a new one. return new ProgressDatabase(); } Json json = new Json(); ProgressDatabase progressDatabase = json.fromJson(ProgressDatabase.class, jsonString); if (progressDatabase != null) { return progressDatabase; } } // Always return a fresh db, // if something is mucked up. // Only executes if something is wrong // with the return new ProgressDatabase(); }
From source file:com.andgate.pokeadot.HighScoreService.java
License:Open Source License
public static HighScore get() { FileHandle saveFile = Gdx.files.external(HIGHSCORE_EXTERNAL_PATH); if (saveFile.exists()) { String jsonString;//from w ww . ja va 2 s .co m try { jsonString = Base64Coder.decodeString(saveFile.readString()); } catch (java.lang.IllegalArgumentException e) { // The highscore has been tampered with, // so now they get a new one. return new HighScore(); } Json json = new Json(); /*json.setTypeName(null); json.setUsePrototypes(false); json.setIgnoreUnknownFields(true); json.setOutputType(JsonWriter.OutputType.json);*/ HighScore highScore = json.fromJson(HighScore.class, jsonString); if (highScore != null) { return highScore; } } return new HighScore(); }