Package com.badlogic.gdx.files

Examples of com.badlogic.gdx.files.FileHandle


      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


    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

  /**
   * Lee y genera el nivel desde un fichero de nivel
   */
  public void readCurrentLevelFile() {
   
    FileHandle file = Gdx.files.internal("levels/level" + currentLevel + ".txt");
    String levelInfo = file.readString();
   
    steps = levelInfo.split("\n");
  }
View Full Code Here

            {
                add("bmp");
            }
        };
        FileHandle directory = resolve(fileName);
        files.clear();
        for(FileHandle file : directory.list()) {
            if(file.isDirectory() || !acceptedFiles.contains(file.extension(), false)) continue;
            files.add(file);
            deps.add(new AssetDescriptor(file.path(), Pixmap.class));
        }
        return deps;
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);

            Format format = Format.valueOf(readValue(reader));

            readTuple(reader);
            TextureFilter min = TextureFilter.valueOf(tuple[0]);
View Full Code Here

    Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
    pixmap.dispose();
    FileHandle atlasFile = Gdx.files.internal(name + ".atlas");
    TextureAtlasData data = !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
    TextureAtlas atlas = new TextureAtlas(data) {
      public AtlasRegion findRegion (String name) {
        AtlasRegion region = super.findRegion(name);
        return region != null ? region : fake;
      }
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);

            Format format = Format.valueOf(readValue(reader));

            readTuple(reader);
            TextureFilter min = TextureFilter.valueOf(tuple[0]);
View Full Code Here

  /** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas"
   * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is
   * automatically disposed when the skin is disposed. */
  public Skin (FileHandle skinFile) {
    FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas");
    if (atlasFile.exists()) {
      atlas = new TextureAtlas(atlasFile);
      addRegions(atlas);
    }

    load(skinFile);
View Full Code Here

    json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
      public BitmapFont read (Json json, JsonValue jsonData, Class type) {
        String path = json.readValue("file", String.class, jsonData);

        FileHandle fontFile = skinFile.parent().child(path);
        if (!fontFile.exists()) fontFile = Gdx.files.internal(path);
        if (!fontFile.exists()) throw new SerializationException("Font file not found: " + fontFile);

        // Use a region with the same name as the font, else use a PNG file in the same directory as the FNT file.
        String regionName = fontFile.nameWithoutExtension();
        try {
          TextureRegion region = skin.optional(regionName, TextureRegion.class);
          if (region != null)
            return new BitmapFont(fontFile, region, false);
          else {
            FileHandle imageFile = fontFile.parent().child(regionName + ".png");
            if (imageFile.exists())
              return new BitmapFont(fontFile, imageFile, false);
            else
              return new BitmapFont(fontFile, false);
          }
        } catch (RuntimeException ex) {
View Full Code Here

        format = parameter.format;
        genMipMaps = parameter.genMipMaps;
        texture = parameter.texture;
      }

      FileHandle handle = resolve(fileName);
      pixmap = new Pixmap(handle);
      data = new FileTextureData(handle, pixmap, format, genMipMaps);
    } else {
      data = parameter.textureData;
      if (!data.isPrepared()) data.prepare();
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.