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

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


          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

 
    for (int y = startY; y <= endY; y++) {
      for (int x = startX; x <= endX; x++) {
        int xCell = (int) (x / TiledMapManager.collisionLayer.getTileWidth());
        int yCell = (int) (y / TiledMapManager.collisionLayer.getTileHeight());
        Cell cell = TiledMapManager.collisionLayer.getCell(xCell, yCell);
       
        // Si es un bloque se a�ade para comprobar colisiones
        if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.BLOCKED))) {
          Rectangle rect = rectPool.obtain();
         
          rect.set((int) (Math.ceil(x / 16f) * 16), (int) (Math.ceil(y / 16f) * 16), 0, 0);
          tiles.add(rect);
        }
View Full Code Here

 
    for (int y = startY; y <= endY; y++) {
      for (int x = startX; x <= endX; x++) {
        int xCell = (int) (x / TiledMapManager.collisionLayer.getTileWidth());
        int yCell = (int) (y / TiledMapManager.collisionLayer.getTileHeight());
        Cell cell = TiledMapManager.collisionLayer.getCell(xCell, yCell);
       
        // Si es un bloque se añade para comprobar colisiones
        if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.BLOCKED))) {
          Rectangle rect = rectPool.obtain();
         
          rect.set((int) (Math.ceil(x / 16f) * 16), (int) (Math.ceil(y / 16f) * 16), 0, 0);
          tiles.add(rect);
        }
View Full Code Here

 
    for (int y = startY; y <= endY; y++) {
      for (int x = startX; x <= endX; x++) {
        int xCell = (int) (x / tileWidth);
        int yCell = (int) (y / tileHeight);
        Cell cell = TiledMapManager.collisionLayer.getCell(xCell, yCell);
       
        // Si es un bloque se añade para comprobar colisiones
        if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.BLOCKED))) {
          Rectangle rect = rectPool.obtain();
          // El jugador está saltando (se choca con la cabeza en una celda)
          if (velocity.y > 0)
            rect.set(x, y, 1, 1);
          // El jugador está cayendo (se posa en la celda que tenga debajo)
          else
            rect.set((int) (Math.ceil(x / tileWidth) * tileWidth), (int) (Math.ceil(y / tileHeight) * tileHeight), 0, 0);
         
          tiles.add(rect);
         
          if (velocity.y > 0)
            if (cell.getTile().getProperties().containsKey(TiledMapManager.BOX)) {
             
              // Sale el item de la caja
              ResourceManager.getSound("sounds/item_appears.wav").play();
              spriteManager.levelManager.raiseItem((int) (Math.ceil(x / tileWidth) * tileWidth),
                           (int) (Math.ceil(y / tileHeight) * tileHeight));
             
              cell.setTile(TiledMapManager.getEmptyBox(spriteManager.levelManager.map));
            }
        }
        // Si es una moneda, desaparece
        else if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.COIN))) {
                    ResourceManager.getSound("sounds/coin.wav").play();
          spriteManager.levelManager.removeCoin(xCell, yCell);
        }
        // Si es un enemigo pierde una vida
        else if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.ENEMY))) {
          if (!dead) {
            die();
          }
        }
        // Si es un cofre se abre y se termina la pantalla
        else if ((cell != null) && (cell.getTile().getProperties().containsKey(TiledMapManager.CHEST))) {

          if (!levelCleared) {
            levelCleared = true;

                        spriteManager.music.stop();
View Full Code Here

      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);
        if (cell == null)
          continue;
        if (cell.getTile().getProperties().containsKey(ANIMATION) &&
          cell.getTile().getProperties().get(ANIMATION, String.class).equals(animationString)) {
          cell.setTile(animatedTile);
        }
      }
    }
  }
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

          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.