Package com.badlogic.gdx.maps.tiled.TiledMapTileLayer

Examples of com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell


            currentTileSet = tilesets.getTileSet(currentChild.getAttribute("Ref"));
            firstgid = currentTileSet.getProperties().get("firstgid", Integer.class);
          } else if (name.equals("Null")) {
            x += currentChild.getIntAttribute("Count");
          } else if (name.equals("Static")) {
            Cell cell = new Cell();
            cell.setTile(currentTileSet.getTile(firstgid + currentChild.getIntAttribute("Index")));
            layer.setCell(x++, y, cell);
          } else if (name.equals("Animated")) {
            // Create an AnimatedTile
            int interval = currentChild.getInt("Interval");
            Element frames = currentChild.getChildByName("Frames");
            Array<StaticTiledMapTile> frameTiles = new Array<StaticTiledMapTile>();
            for (int frameChild = 0, frameChildCount = frames.getChildCount(); frameChild < frameChildCount; frameChild++) {
              Element frame = frames.getChild(frameChild);
              String frameName = frame.getName();
              if (frameName.equals("TileSheet")) {
                currentTileSet = tilesets.getTileSet(frame.getAttribute("Ref"));
                firstgid = currentTileSet.getProperties().get("firstgid", Integer.class);
              } else if (frameName.equals("Static")) {
                frameTiles.add((StaticTiledMapTile)currentTileSet.getTile(firstgid + frame.getIntAttribute("Index")));
              }
            }
            Cell cell = new Cell();
            cell.setTile(new AnimatedTiledMapTile(interval / 1000f, frameTiles));
            layer.setCell(x++, y, cell); // TODO: Reuse existing animated tiles
          }
        }
      }
      map.getLayers().add(layer);
View Full Code Here


          boolean flipVertically = ((id & FLAG_FLIP_VERTICALLY) != 0);
          boolean flipDiagonally = ((id & FLAG_FLIP_DIAGONALLY) != 0);

          TiledMapTile tile = tilesets.getTile(id & ~MASK_CLEAR);
          if (tile != null) {
            Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
            cell.setTile(tile);
            layer.setCell(x, height - 1 - y, cell);
          }
        }
      }
View Full Code Here

      }
    }
  }

  protected Cell createTileLayerCell (boolean flipHorizontally, boolean flipVertically, boolean flipDiagonally) {
    Cell cell = new Cell();
    if (flipDiagonally) {
      if (flipHorizontally && flipVertically) {
        cell.setFlipHorizontally(true);
        cell.setRotation(Cell.ROTATE_270);
      } else if (flipHorizontally) {
        cell.setRotation(Cell.ROTATE_270);
      } else if (flipVertically) {
        cell.setRotation(Cell.ROTATE_90);
      } else {
        cell.setFlipVertically(true);
        cell.setRotation(Cell.ROTATE_270);
      }
    } else {
      cell.setFlipHorizontally(flipHorizontally);
      cell.setFlipVertically(flipVertically);
    }
    return cell;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell

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.