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

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


            id = id & ~MASK_CLEAR;

            tilesets.getTile(id);
            TiledMapTile tile = tilesets.getTile(id);
            if (tile != null) {
              Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
              cell.setTile(tile);
              layer.setCell(x, yUp ? height - 1 - y : y, cell);
            }
          }
        }
      } else {
        if (encoding.equals("base64")) {
          byte[] bytes = Base64Coder.decode(data.getText());
          if (compression == null) {
            int read = 0;
            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {

                int id = unsignedByteToInt(bytes[read++]) | unsignedByteToInt(bytes[read++]) << 8
                  | unsignedByteToInt(bytes[read++]) << 16 | unsignedByteToInt(bytes[read++]) << 24;

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

                id = id & ~MASK_CLEAR;

                tilesets.getTile(id);
                TiledMapTile tile = tilesets.getTile(id);
                if (tile != null) {
                  Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                  cell.setTile(tile);
                  layer.setCell(x, yUp ? height - 1 - y : y, cell);
                }
              }
            }
          } else if (compression.equals("gzip")) {
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(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipHorizontally) {
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipVertically) {
        cell.setRotation(yUp ? Cell.ROTATE_90 : Cell.ROTATE_270);
      } else {
        cell.setFlipVertically(true);
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      }
    } else {
      cell.setFlipHorizontally(flipHorizontally);
      cell.setFlipVertically(flipVertically);
    }
    return cell;
  }
View Full Code Here

            id = id & ~MASK_CLEAR;

            tilesets.getTile(id);
            TiledMapTile tile = tilesets.getTile(id);
            if (tile != null) {
              Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
              cell.setTile(tile);
              layer.setCell(x, yUp ? height - 1 - y : y, cell);
            }
          }
        }
      } else {
        if (encoding.equals("base64")) {
          byte[] bytes = Base64Coder.decode(data.getText());
          if (compression == null) {
            int read = 0;
            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {

                int id = unsignedByteToInt(bytes[read++]) | unsignedByteToInt(bytes[read++]) << 8
                  | unsignedByteToInt(bytes[read++]) << 16 | unsignedByteToInt(bytes[read++]) << 24;

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

                id = id & ~MASK_CLEAR;

                tilesets.getTile(id);
                TiledMapTile tile = tilesets.getTile(id);
                if (tile != null) {
                  Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                  cell.setTile(tile);
                  layer.setCell(x, yUp ? height - 1 - y : y, cell);
                }
              }
            }
          } else if (compression.equals("gzip")) {
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(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipHorizontally) {
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipVertically) {
        cell.setRotation(yUp ? Cell.ROTATE_90 : Cell.ROTATE_270);
      } else {
        cell.setFlipVertically(true);
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      }
    } else {
      cell.setFlipHorizontally(flipHorizontally);
      cell.setFlipVertically(flipVertically);
    }
    return cell;
  }
View Full Code Here

            id = id & ~MASK_CLEAR;

            tilesets.getTile(id);
            TiledMapTile tile = tilesets.getTile(id);
            if (tile != null) {
              Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
              cell.setTile(tile);
              layer.setCell(x, yUp ? height - 1 - y : y, cell);
            }
          }
        }
      } else {
        if (encoding.equals("base64")) {
          byte[] bytes = Base64Coder.decode(data.getText());
          if (compression == null) {
            int read = 0;
            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {

                int id = unsignedByteToInt(bytes[read++]) | unsignedByteToInt(bytes[read++]) << 8
                  | unsignedByteToInt(bytes[read++]) << 16 | unsignedByteToInt(bytes[read++]) << 24;

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

                id = id & ~MASK_CLEAR;

                tilesets.getTile(id);
                TiledMapTile tile = tilesets.getTile(id);
                if (tile != null) {
                  Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                  cell.setTile(tile);
                  layer.setCell(x, yUp ? height - 1 - y : y, cell);
                }
              }
            }
          } else if (compression.equals("gzip")) {
            GZIPInputStream GZIS = null;
            try {
              GZIS = new GZIPInputStream(new ByteArrayInputStream(bytes), bytes.length);
            } catch (IOException e) {
              throw new GdxRuntimeException("Error Reading TMX Layer Data - IOException: " + e.getMessage());
            }

            byte[] temp = new byte[4];
            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {
                try {
                  GZIS.read(temp, 0, 4);
                  int id = unsignedByteToInt(temp[0]) | unsignedByteToInt(temp[1]) << 8
                    | unsignedByteToInt(temp[2]) << 16 | unsignedByteToInt(temp[3]) << 24;

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

                  id = id & ~MASK_CLEAR;

                  tilesets.getTile(id);
                  TiledMapTile tile = tilesets.getTile(id);
                  if (tile != null) {
                    Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                    cell.setTile(tile);
                    layer.setCell(x, yUp ? height - 1 - y : y, cell);
                  }
                } catch (IOException e) {
                  throw new GdxRuntimeException("Error Reading TMX Layer Data.", e);
                }
              }
            }
          } else if (compression.equals("zlib")) {
            Inflater zlib = new Inflater();

            byte[] temp = new byte[4];

            zlib.setInput(bytes, 0, bytes.length);

            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {
                try {
                  zlib.inflate(temp, 0, 4);
                  int id = unsignedByteToInt(temp[0]) | unsignedByteToInt(temp[1]) << 8
                    | unsignedByteToInt(temp[2]) << 16 | unsignedByteToInt(temp[3]) << 24;

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

                  id = id & ~MASK_CLEAR;

                  tilesets.getTile(id);
                  TiledMapTile tile = tilesets.getTile(id);
                  if (tile != null) {
                    Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                    cell.setTile(tile);
                    layer.setCell(x, yUp ? height - 1 - y : y, cell);
                  }

                } catch (DataFormatException e) {
                  throw new GdxRuntimeException("Error Reading TMX Layer Data.", e);
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(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipHorizontally) {
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipVertically) {
        cell.setRotation(yUp ? Cell.ROTATE_90 : Cell.ROTATE_270);
      } else {
        cell.setFlipVertically(true);
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      }
    } else {
      cell.setFlipHorizontally(flipHorizontally);
      cell.setFlipVertically(flipVertically);
    }
    return cell;
  }
View Full Code Here

            id = id & ~MASK_CLEAR;

            tilesets.getTile(id);
            TiledMapTile tile = tilesets.getTile(id);
            if (tile != null) {
              Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
              cell.setTile(tile);
              layer.setCell(x, yUp ? height - 1 - y : y, cell);
            }
          }
        }
      } else {
        if (encoding.equals("base64")) {
          byte[] bytes = Base64Coder.decode(data.getText());
          if (compression == null) {
            int read = 0;
            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {

                int id = unsignedByteToInt(bytes[read++]) | unsignedByteToInt(bytes[read++]) << 8
                  | unsignedByteToInt(bytes[read++]) << 16 | unsignedByteToInt(bytes[read++]) << 24;

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

                id = id & ~MASK_CLEAR;

                tilesets.getTile(id);
                TiledMapTile tile = tilesets.getTile(id);
                if (tile != null) {
                  Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                  cell.setTile(tile);
                  layer.setCell(x, yUp ? height - 1 - y : y, cell);
                }
              }
            }
          } else if (compression.equals("gzip")) {
            GZIPInputStream GZIS = null;
            try {
              GZIS = new GZIPInputStream(new ByteArrayInputStream(bytes), bytes.length);
            } catch (IOException e) {
              throw new GdxRuntimeException("Error Reading TMX Layer Data - IOException: " + e.getMessage());
            }

            byte[] temp = new byte[4];
            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {
                try {
                  GZIS.read(temp, 0, 4);
                  int id = unsignedByteToInt(temp[0]) | unsignedByteToInt(temp[1]) << 8
                    | unsignedByteToInt(temp[2]) << 16 | unsignedByteToInt(temp[3]) << 24;

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

                  id = id & ~MASK_CLEAR;

                  tilesets.getTile(id);
                  TiledMapTile tile = tilesets.getTile(id);
                  if (tile != null) {
                    Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                    cell.setTile(tile);
                    layer.setCell(x, yUp ? height - 1 - y : y, cell);
                  }
                } catch (IOException e) {
                  throw new GdxRuntimeException("Error Reading TMX Layer Data.", e);
                }
              }
            }
          } else if (compression.equals("zlib")) {
            Inflater zlib = new Inflater();

            byte[] temp = new byte[4];

            zlib.setInput(bytes, 0, bytes.length);

            for (int y = 0; y < height; y++) {
              for (int x = 0; x < width; x++) {
                try {
                  zlib.inflate(temp, 0, 4);
                  int id = unsignedByteToInt(temp[0]) | unsignedByteToInt(temp[1]) << 8
                    | unsignedByteToInt(temp[2]) << 16 | unsignedByteToInt(temp[3]) << 24;

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

                  id = id & ~MASK_CLEAR;

                  tilesets.getTile(id);
                  TiledMapTile tile = tilesets.getTile(id);
                  if (tile != null) {
                    Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally);
                    cell.setTile(tile);
                    layer.setCell(x, yUp ? height - 1 - y : y, cell);
                  }

                } catch (DataFormatException e) {
                  throw new GdxRuntimeException("Error Reading TMX Layer Data.", e);
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(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipHorizontally) {
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      } else if (flipVertically) {
        cell.setRotation(yUp ? Cell.ROTATE_90 : Cell.ROTATE_270);
      } else {
        cell.setFlipVertically(true);
        cell.setRotation(yUp ? Cell.ROTATE_270 : Cell.ROTATE_90);
      }
    } 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.