Package com.badlogic.gdx.files

Examples of com.badlogic.gdx.files.FileHandle


    return handle;
  }

  protected String resolve (FileHandle originalHandle, String suffix) {
    String parentString = "";
    FileHandle parent = originalHandle.parent();
    if (parent != null && !parent.name().equals("")) {
      parentString = parent + "/";
    }   
    return parentString + suffix + "/" + originalHandle.name();
  }
View Full Code Here


    super(resolver);
  }

  public TiledMap load (String fileName) {
    try {
      FileHandle tideFile = resolve(fileName);
      root = xml.parse(tideFile);
      ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();
      for (FileHandle textureFile : loadTileSheets(root, tideFile)) {
        textures.put(textureFile.path(), new Texture(textureFile));
      }
View Full Code Here

  private Array<FileHandle> loadTileSheets (Element root, FileHandle tideFile) throws IOException {
    Array<FileHandle> images = new Array<FileHandle>();
    Element tilesheets = root.getChildByName("TileSheets");
    for (Element tileset : tilesheets.getChildrenByName("TileSheet")) {
      Element imageSource = tileset.getChildByName("ImageSource");
      FileHandle image = getRelativeFileHandle(tideFile, imageSource.getText());
      images.add(image);
    }
    return images;
  }
View Full Code Here

      String[] spacingParts = margin.split(" x ");
      int spacingX = Integer.parseInt(spacingParts[0]);
      int spacingY = Integer.parseInt(spacingParts[1]);

      FileHandle image = getRelativeFileHandle(tideFile, imageSource);
      TextureRegion texture = imageResolver.getImage(image.path());

      TiledMapTileSets tilesets = map.getTileSets();
      int firstgid = 1;
      for (TiledMapTileSet tileset : tilesets) {
        firstgid += tileset.size();
View Full Code Here

    }
  }

  private static FileHandle getRelativeFileHandle (FileHandle file, String path) {
    StringTokenizer tokenizer = new StringTokenizer(path, "\\/");
    FileHandle result = file.parent();
    while (tokenizer.hasMoreElements()) {
      String token = tokenizer.nextToken();
      if (token.equals(".."))
        result = result.parent();
      else {
        result = result.child(token);
      }
    }
    return result;
  }
View Full Code Here

  // Tries to load the bundle for the given locale.
  private static I18NBundle loadBundle (FileHandle baseFileHandle, String encoding, Locale targetLocale) {
    I18NBundle bundle = null;
    InputStream stream = null;
    try {
      FileHandle fileHandle = toFileHandle(baseFileHandle, targetLocale);
      if (fileHandle.exists()) {
        // Instantiate the bundle
        bundle = new I18NBundle();

        // Load bundle properties from the stream with the specified encoding
        stream = fileHandle.read();
        bundle.load(new InputStreamReader(stream, encoding));
      }
    } catch (Throwable t) {
      throw new GdxRuntimeException(t);
    } finally {
View Full Code Here

          String line = reader.readLine();
          if (line == null) break;
          if (line.trim().length() == 0)
            pageImage = null;
          else if (pageImage == null) {
            FileHandle file = imagesDir.child(line);

            float width = 0, height = 0;
            if (readTuple(reader) == 2) { // size is only optional for an atlas packed with an old TexturePacker.
              width = Integer.parseInt(tuple[0]);
              height = Integer.parseInt(tuple[1]);
View Full Code Here

   * @param parameters specifies whether to use y-up, generate mip maps etc.
   * @return the TiledMap */
  public TiledMap load (String fileName, TmxMapLoader.Parameters parameters) {
    try {
      this.convertObjectToTileSpace = parameters.convertObjectToTileSpace;
      FileHandle tmxFile = resolve(fileName);
      root = xml.parse(tmxFile);
      ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();
      for (FileHandle textureFile : loadTilesets(root, tmxFile)) {
        Texture texture = new Texture(textureFile, parameters.generateMipMaps);
        texture.setFilter(parameters.textureMinFilter, parameters.textureMagFilter);
View Full Code Here

   * @throws IOException */
  protected Array<FileHandle> loadTilesets (Element root, FileHandle tmxFile) throws IOException {
    Array<FileHandle> images = new Array<FileHandle>();
    for (Element tileset : root.getChildrenByName("tileset")) {
      String source = tileset.getAttribute("source", null);
      FileHandle image = null;
      if (source != null) {
        FileHandle tsx = getRelativeFileHandle(tmxFile, source);
        tileset = xml.parse(tsx);
        String imageSource = tileset.getChildByName("image").getAttribute("source");
        image = getRelativeFileHandle(tsx, imageSource);
      } else {
        String imageSource = tileset.getChildByName("image").getAttribute("source");
View Full Code Here

      int offsetY = 0;

      String imageSource = "";
      int imageWidth = 0, imageHeight = 0;

      FileHandle image = null;
      if (source != null) {
        FileHandle tsx = getRelativeFileHandle(tmxFile, source);
        try {
          element = xml.parse(tsx);
          name = element.get("name", null);
          tilewidth = element.getIntAttribute("tilewidth", 0);
          tileheight = element.getIntAttribute("tileheight", 0);
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.files.FileHandle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.