Package com.badlogic.gdx.maps.tiled

Examples of com.badlogic.gdx.maps.tiled.TiledMapTile


   
    // Localiza los tiles anotados como animaciones en el tileset
    Array<StaticTiledMapTile> frameTiles = new Array<StaticTiledMapTile>(n);
    Iterator<TiledMapTile> tiles = TiledMapManager.levelManager.map.getTileSets().getTileSet("tileset").iterator();
    while (tiles.hasNext()) {
      TiledMapTile tile = tiles.next();
      if ((tile.getProperties().containsKey(ANIMATION)) && (tile.getProperties().get(ANIMATION, String.class).equals(animationString))) {
        frameTiles.add((StaticTiledMapTile) tile);
      }
    }
   
    // Crea un tile animado y le asigna las propiedades de todos los tiles que forman la animación
    AnimatedTiledMapTile animatedTile = new AnimatedTiledMapTile(1 / 4f, frameTiles);
    // El Tile animado tiene que heredar todas las propiedades de los tiles estáticos que lo forman
    for (TiledMapTile tile : frameTiles)
      animatedTile.getProperties().putAll(tile.getProperties());
   
    // Coloca el tile animado donde haya un tile del mismo tipo pero estático
    for (int x = 0; x < collisionLayer.getWidth(); x++) {
      for (int y = 0; y < collisionLayer.getHeight(); y++) {
        Cell cell = collisionLayer.getCell(x, y);
View Full Code Here


   */
  public static TiledMapTile getEmptyBox(TiledMap map) {
   
    Iterator<TiledMapTile> tiles = map.getTileSets().getTileSet("tileset").iterator();
    while (tiles.hasNext()) {
      TiledMapTile tile = tiles.next();
      if ((tile.getProperties().containsKey("empty_box"))) {
        return tile;
      }
    }
   
    return null;
View Full Code Here

    for (int y = layer.getHeight() - 1; y >= 0; y--) {
      for (int x = layer.getWidth() - 1; x >= 0; x--) {
        final TiledMapTileLayer.Cell cell = layer.getCell(x, y);
        if (cell == null) continue;
        final TiledMapTile tile = cell.getTile();

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();
          TextureRegion region = tile.getTextureRegion();

          float x1 = (x * tileWidth) - ((y % 2 == 1) ? halfTileWidth : 0);
          float y1 = y * halfTileHeight;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;
 
View Full Code Here

        float x = (col * halfTileWidth) + (row * halfTileWidth);
        float y = (row * halfTileHeight) - (col * halfTileHeight);

        final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
        if(cell == null) continue;
        final TiledMapTile tile = cell.getTile();

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x;
          float y1 = y;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;
 
View Full Code Here

        final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
        if(cell == null) {
          x += layerTileWidth;
          continue;
        }
        final TiledMapTile tile = cell.getTile();

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x;
          float y1 = y;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;
 
View Full Code Here

        final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
        if(cell == null) {
          x += layerTileWidth;
          continue;
        }
        final TiledMapTile tile = cell.getTile();
        if (tile != null) {
          if (tile instanceof AnimatedTiledMapTile) continue;

          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x;
          float y1 = y;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;
 
View Full Code Here

                final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
                if (cell == null) {
                    x += layerTileWidth;
                    continue;
                }
                final TiledMapTile tile = cell.getTile();
                if (tile != null) {
                    final boolean flipX = cell.getFlipHorizontally();
                    final boolean flipY = cell.getFlipVertically();
                    final int rotations = cell.getRotation();

                    TextureRegion region = tile.getTextureRegion();

                    float x1 = x;
                    float y1 = y;
                    float x2 = x1 + region.getRegionWidth() * unitScale;
                    float y2 = y1 + region.getRegionHeight() * unitScale;
 
View Full Code Here

        float x = (col * halfTileWidth) + (row * halfTileWidth);
        float y = (row * halfTileHeight) - (col * halfTileHeight);

        final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
        if (cell == null) continue;
        final TiledMapTile tile = cell.getTile();

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x + tile.getOffsetX() * unitScale;
          float y1 = y + tile.getOffsetY() * unitScale;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;

          float u1 = region.getU();
          float v1 = region.getV2();
View Full Code Here

        final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
        if (cell == null) {
          x += layerTileWidth;
          continue;
        }
        final TiledMapTile tile = cell.getTile();

        if (tile != null) {
          final boolean flipX = cell.getFlipHorizontally();
          final boolean flipY = cell.getFlipVertically();
          final int rotations = cell.getRotation();

          TextureRegion region = tile.getTextureRegion();

          float x1 = x + tile.getOffsetX() * unitScale;
          float y1 = y + tile.getOffsetY() * unitScale;
          float x2 = x1 + region.getRegionWidth() * unitScale;
          float y2 = y1 + region.getRegionHeight() * unitScale;

          float u1 = region.getU();
          float v1 = region.getV2();
View Full Code Here

    for (int row = row2; row >= row1; row--) {
      for (int col = col1; col < col2; col++) {
        final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
        if (cell == null) continue;

        final TiledMapTile tile = cell.getTile();
        if (tile == null) continue;

        count++;
        final boolean flipX = cell.getFlipHorizontally();
        final boolean flipY = cell.getFlipVertically();
        final int rotations = cell.getRotation();

        final TextureRegion region = tile.getTextureRegion();
        final Texture texture = region.getTexture();

        final float x1 = col * layerTileWidth + tile.getOffsetX() * unitScale;
        final float y1 = row * layerTileHeight + tile.getOffsetY() * unitScale;
        final float x2 = x1 + region.getRegionWidth() * unitScale;
        final float y2 = y1 + region.getRegionHeight() * unitScale;

        final float adjustX = 0.5f / texture.getWidth();
        final float adjustY = 0.5f / texture.getHeight();
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.maps.tiled.TiledMapTile

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.