Package com.badlogic.gdx.files

Examples of com.badlogic.gdx.files.FileHandle


          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


  static final String externalPath = appDir + "/Documents";
  static final String localPath = appDir + "/Library/local";
  static final String internalPath = NSBundle.getMainBundle().getBundlePath();
 
  public IOSFiles() {
    new FileHandle(externalPath).mkdirs();
    new FileHandle(localPath).mkdirs();
  }
View Full Code Here

  public void saveEffect (File file) {
    Writer fileWriter = null;
    try {
      ParticleEffectLoader loader = (ParticleEffectLoader)assetManager.getLoader(ParticleEffect.class);
      loader.save(effect, new ParticleEffectSaveParameter(new FileHandle(file.getAbsolutePath()), assetManager, particleSystem.getBatches()));
    } catch (Exception ex) {
      System.out.println("Error saving effect: " + file.getAbsolutePath());
      ex.printStackTrace();
      JOptionPane.showMessageDialog(this, "Error saving effect.");
    } finally {
View Full Code Here

      File outputFile;
      while (true) {
        outputFile = new File(packDir, imageName + (fileIndex++ == 0 ? "" : fileIndex) + "." + settings.outputFormat);
        if (!outputFile.exists()) break;
      }
      new FileHandle(outputFile).parent().mkdirs();
      page.imageName = outputFile.getName();

      BufferedImage canvas = new BufferedImage(width, height, getBufferedImageType(settings.format));
      Graphics2D g = (Graphics2D)canvas.getGraphics();
View Full Code Here

  }

  private void writePackFile (File packFile, Array<Page> pages) throws IOException {
    if (packFile.exists()) {
      // Make sure there aren't duplicate names.
      TextureAtlasData textureAtlasData = new TextureAtlasData(new FileHandle(packFile), new FileHandle(packFile), false);
      for (Page page : pages) {
        for (Rect rect : page.outputRects) {
          String rectName = Rect.getAtlasName(rect.name, settings.flattenPaths);
          for (Region region : textureAtlasData.getRegions()) {
            if (region.name.equals(rectName)) {
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.yUp = parameters.yUp;
      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

      String source = element.getAttribute("source", null);

      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

    return cell;
  }

  protected 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

    public String toString () {
      return name + "[" + x + "," + y + " " + width + "x" + height + "]";
    }

    static public String getAtlasName (String name, boolean flattenPaths) {
      return flattenPaths ? new FileHandle(name).name() : name;
    }
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.