renderCell(layer.getCell(col, row), tileWidthUpperCorner * col + layerOffsetX, layerTileHeight50 + (layerTileHeight * row) + layerOffsetY, color); renderCell(layer.getCell(col, row), tileWidthUpperCorner * col + layerOffsetX, layerTileHeight * row + layerOffsetY, color); shiftX = 0; for (int col = col1; col < col2; col++) { renderCell(layer.getCell(col, row), layerTileWidth * col + shiftX + layerOffsetX, tileHeightUpperCorner * row + layerOffsetY, color);
renderCell(layer.getCell(col, row), tileWidthUpperCorner * col + layerOffsetX, layerTileHeight50 + (layerTileHeight * row) + layerOffsetY, color); renderCell(layer.getCell(col, row), tileWidthUpperCorner * col + layerOffsetX, layerTileHeight * row + layerOffsetY, color); shiftX = 0; for (int col = col1; col < col2; col++) { renderCell(layer.getCell(col, row), layerTileWidth * col + shiftX + layerOffsetX, tileHeightUpperCorner * row + layerOffsetY, color);
private void stripUnusedTiles () { int mapWidth = map.getProperties().get("width", Integer.class); int mapHeight = map.getProperties().get("height", Integer.class); int numlayers = map.getLayers().getCount(); int bucketSize = mapWidth * mapHeight * numlayers; Iterator<MapLayer> it = map.getLayers().iterator(); while (it.hasNext()) { MapLayer layer = it.next(); // some layers can be plain MapLayer instances (ie. object groups), just ignore them if (layer instanceof TiledMapTileLayer) { TiledMapTileLayer tlayer = (TiledMapTileLayer)layer; for (int y = 0; y < mapHeight; ++y) { for (int x = 0; x < mapWidth; ++x) { if (tlayer.getCell(x, y) != null) { TiledMapTile tile = tlayer.getCell(x, y).getTile(); if (tile instanceof AnimatedTiledMapTile) { AnimatedTiledMapTile aTile = (AnimatedTiledMapTile)tile; for (StaticTiledMapTile t : aTile.getFrameTiles()) { addTile(t, bucketSize); } } // Adds non-animated tiles and the base animated tile addTile(tile, bucketSize); } } } } } }
private void stripUnusedTiles () { int mapWidth = map.getProperties().get("width", Integer.class); int mapHeight = map.getProperties().get("height", Integer.class); int numlayers = map.getLayers().getCount(); int bucketSize = mapWidth * mapHeight * numlayers; Iterator<MapLayer> it = map.getLayers().iterator(); while (it.hasNext()) { MapLayer layer = it.next(); // some layers can be plain MapLayer instances (ie. object groups), just ignore them if (layer instanceof TiledMapTileLayer) { TiledMapTileLayer tlayer = (TiledMapTileLayer)layer; for (int y = 0; y < mapHeight; ++y) { for (int x = 0; x < mapWidth; ++x) { if (tlayer.getCell(x, y) != null) { TiledMapTile tile = tlayer.getCell(x, y).getTile(); if (tile instanceof AnimatedTiledMapTile) { AnimatedTiledMapTile aTile = (AnimatedTiledMapTile)tile; for (StaticTiledMapTile t : aTile.getFrameTiles()) { addTile(t, bucketSize); } } // Adds non-animated tiles and the base animated tile addTile(tile, bucketSize); } } } } } }
private void getTiles (int startX, int startY, int endX, int endY, Array<Rectangle> tiles) { TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("walls"); rectPool.freeAll(tiles); tiles.clear(); for (int y = startY; y <= endY; y++) { for (int x = startX; x <= endX; x++) { Cell cell = layer.getCell(x, y); if (cell != null) { Rectangle rect = rectPool.obtain(); rect.set(x, y, 1, 1); tiles.add(rect); } } } }
private void renderDebug () { debugRenderer.setProjectionMatrix(camera.combined); debugRenderer.begin(ShapeType.Line); debugRenderer.setColor(Color.RED); debugRenderer.rect(koala.position.x, koala.position.y, Koala.WIDTH, Koala.HEIGHT); debugRenderer.setColor(Color.YELLOW); TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get("walls"); for (int y = 0; y <= layer.getHeight(); y++) { for (int x = 0; x <= layer.getWidth(); x++) { Cell cell = layer.getCell(x, y); if (cell != null) { if (camera.frustum.boundsInFrustum(x + 0.5f, y + 0.5f, 0, 1, 1, 0)) debugRenderer.rect(x, y, 1, 1); } } } debugRenderer.end(); }
float x = xStart; for (int col = col1; col < col2; col++) { final TiledMapTileLayer.Cell cell = layer.getCell(col, row); if (cell == null) { x += layerTileWidth;
float offsetX = (y % 2 == 1) ? layerTileWidth50 : 0; for (int x = maxX - 1; x >= minX; x--) { final TiledMapTileLayer.Cell cell = layer.getCell(x, y); if (cell == null) continue; final TiledMapTile tile = cell.getTile();
float offsetX = (y % 2 == 1) ? layerTileWidth50 : 0; for (int x = maxX - 1; x >= minX; x--) { final TiledMapTileLayer.Cell cell = layer.getCell(x, y); if (cell == null) continue; final TiledMapTile tile = cell.getTile();
float x = xStart; for (int col = col1; col < col2; col++) { final TiledMapTileLayer.Cell cell = layer.getCell(col, row); if (cell == null) { x += layerTileWidth;
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;
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;
float y = (row * halfTileHeight) - (col * halfTileHeight); final TiledMapTileLayer.Cell cell = layer.getCell(col, row); if (cell == null) continue; final TiledMapTile tile = cell.getTile();
float y = (row * halfTileHeight) - (col * halfTileHeight); final TiledMapTileLayer.Cell cell = layer.getCell(col, row); if (cell == null) continue; final TiledMapTile tile = cell.getTile();
public void getsurroundingTiles(int startX, int startY, int endX, int endY, Array<Rectangle> surroundingTiles){ TiledMapTileLayer layer = (TiledMapTileLayer) worldRef.getCurrentMap().getLayers().get("Terrain"); surroundingTiles.clear(); for (int y = startY; y <= endY; y++) { for (int x = startX; x <= endX; x++) { Cell cell = layer.getCell(x, y); if (cell != null && cell.getTile().getProperties().containsKey("blocked")) { Rectangle rect = new Rectangle(); rect.set(x, y, 1, 1); surroundingTiles.add(rect); } } } }
private void setBlocked() { for (int i = 0; i < this.map.getLayers().getCount(); i++) { TiledMapTileLayer layer = (TiledMapTileLayer) this.map.getLayers() .get(i); for (int y = 0; y < layer.getHeight(); y++) { for (int x = 0; x < layer.getWidth(); x++) { if (layer.getCell(x, y) != null && layer.getCell(x, y).getTile().getProperties() .containsKey("blocked")) { this.mapArray[x][y] = Config.CANTMOVEONPOSITION; } } } } }
public TiledMapTileLayer.Cell getCell(){ TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1); return layer.getCell((int)(body.getPosition().x * MarioBros.PPM / 16), (int)(body.getPosition().y * MarioBros.PPM / 16)); }
private void generate(Array<TiledMapTileLayer> layers, String propertyKey) { for (TiledMapTileLayer layer : layers) { for (int ty = 0; ty < height; ty++) { for (int tx = 0; tx < width; tx++) { final TiledMapTileLayer.Cell cell = layer.getCell(tx, ty); if ( cell != null && cell.getTile() != null && cell.getTile().getProperties().containsKey(propertyKey)) { v[ty][tx] = true; } } } } } }
TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get(1); TiledMapTileLayer.Cell cell = layer.getCell((int)tile.x, (int)tile.y); TiledMapTile tile = cell != null ? cell.getTile() : null; if (tile != null) { switch (tile.getId()) { case TILE_SOLID: cell.setTile(crackedTile); break; case TILE_CRACKED: cell.setTile(null); break; } }
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0); TiledMapTileSet tileset = map.getTileSets().getTileSet(0); Array<StaticTiledMapTile> at = new Array<StaticTiledMapTile>(); if (tileset.getTile(0) != null) at.add((StaticTiledMapTile) tileset.getTile(0)); if (tileset.getTile(1) != null) at.add((StaticTiledMapTile) tileset.getTile(1)); if (tileset.getTile(2) != null) at.add((StaticTiledMapTile) tileset.getTile(2)); if (tileset.getTile(3) != null) at.add((StaticTiledMapTile) tileset.getTile(3)); layer.getCell(2, 2).setTile(new AnimatedTiledMapTile(0.3f, at));