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); } } } } } }
continue; final TiledMapTile tile = cell.getTile();
/** * 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); } } } } } }
/** * 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; } } } } } }
@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); } } }
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; } } } } } }
/** * 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); } } } } } }
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; } }
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; } } } } } }
final TiledMapTile tile = cell.getTile();
continue; final TiledMapTile tile = cell.getTile();
if (cell == null) continue; final TiledMapTile tile = cell.getTile(); if (tile == null) continue;
if (cell == null) continue; final TiledMapTile tile = cell.getTile(); if (tile == null) continue;
final TiledMapTile tile = cell.getTile();
final TiledMapTileLayer.Cell cell = layer.getCell(x, y); if (cell == null) continue; final TiledMapTile tile = cell.getTile();
final TiledMapTileLayer.Cell cell = layer.getCell(x, y); if (cell == null) continue; final TiledMapTile tile = cell.getTile();
final TiledMapTile tile = cell.getTile(); if (tile != null) { if (tile instanceof AnimatedTiledMapTile) return;
final TiledMapTile tile = cell.getTile(); if (tile != null) { if (tile instanceof AnimatedTiledMapTile) return;