continue; final TiledMapTile tile = cell.getTile(); final boolean flipX = cell.getFlipHorizontally(); final boolean flipY = cell.getFlipVertically(); final int rotations = cell.getRotation();
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")) { Cell cell = new Cell(); cell.setTile(new AnimatedTiledMapTile(interval / 1000f, frameTiles));
continue; final TiledMapTile tile = cell.getTile(); final boolean flipX = cell.getFlipHorizontally(); final boolean flipY = cell.getFlipVertically(); final int rotations = cell.getRotation();
final TiledMapTileLayer.Cell cell = layer.getCell(x, y); if (cell == null) continue; final TiledMapTile tile = cell.getTile(); final boolean flipX = cell.getFlipHorizontally(); final boolean flipY = cell.getFlipVertically(); final int rotations = cell.getRotation(); TextureRegion region = tile.getTextureRegion();
final TiledMapTile tile = cell.getTile(); final boolean flipX = cell.getFlipHorizontally(); final boolean flipY = cell.getFlipVertically(); final int rotations = cell.getRotation();
if (cell == null) continue; final TiledMapTile tile = cell.getTile(); if (tile == null) continue; final boolean flipX = cell.getFlipHorizontally(); final boolean flipY = cell.getFlipVertically(); final int rotations = cell.getRotation();
final TiledMapTile tile = cell.getTile(); if (tile != null) { if (tile instanceof AnimatedTiledMapTile) return; final boolean flipX = cell.getFlipHorizontally(); final boolean flipY = cell.getFlipVertically(); final int rotations = cell.getRotation();
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")) { Cell cell = new Cell(); cell.setTile(new AnimatedTiledMapTile(interval / 1000f, frameTiles));
if (tile != null) { Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally); cell.setTile(tile); layer.setCell(x, yUp ? height - 1 - y : y, cell);
int id = layerTrack.getCell((int)tilePosition.x, (int)tilePosition.y).getTile().getId() - 1;
if (tile != null) { Cell cell = createTileLayerCell(flipHorizontally, flipVertically, flipDiagonally); cell.setTile(tile); layer.setCell(x, flipY ? height - 1 - y : y, cell);
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); } } } } } }
/** * Spawn map entities. */ protected void setup() { 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) { final MapProperties properties = cell.getTile().getProperties(); if (properties.containsKey("entity")) { entityFactorySystem.createEntity((String)properties.get("entity"), tx * tileWidth, ty * tileHeight, properties); layer.setCell(tx, ty, null); } } } } } }
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; }
/** * Spawn map entities. */ protected void setup() { 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) { final MapProperties properties = cell.getTile().getProperties(); if (properties.containsKey("entity")) { entityFactorySystem.createEntity((String)properties.get("entity"), tx * tileWidth, ty * tileHeight, properties); layer.setCell(tx, ty, null); } } } } } }
public void generate(Array<TiledMapTileLayer> layers, String propertyKey) { for (int ty = 0; ty < height; ty++) { for (int tx = 0; tx < width; tx++) { v[ty][tx] = false; } } 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; } } } } } }
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; }
public void generate(Array<TiledMapTileLayer> layers, String propertyKey) { for (int ty = 0; ty < height; ty++) { for (int tx = 0; tx < width; tx++) { v[ty][tx] = false; } } 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; } } } } } }
@Override public void onHeadHit(Mario mario) { if(getCell().getTile().getId() == BLANK_COIN) MarioBros.manager.get("audio/sounds/bump.wav", Sound.class).play(); else { if(object.getProperties().containsKey("mushroom")) { screen.spawnItem(new ItemDef(new Vector2(body.getPosition().x, body.getPosition().y + 16 / MarioBros.PPM), Mushroom.class)); MarioBros.manager.get("audio/sounds/powerup_spawn.wav", Sound.class).play(); } else MarioBros.manager.get("audio/sounds/coin.wav", Sound.class).play(); getCell().setTile(tileSet.getTile(BLANK_COIN)); Hud.addScore(100); } } }