/** Returns the object for the given key, casting it to clazz. * @param key the key of the object * @param defaultValue the default value * @param clazz the class of the object * @return the object or the defaultValue if the object is not in the map * @throws ClassCastException if the object with the given key is not of type clazz */ public <T> T get (String key, T defaultValue, Class<T> clazz) { Object object = get(key); return object == null ? defaultValue : (T)object; }
private void loadProperties (MapProperties properties, Element element) { if (element.getName().equals("Properties")) { for (Element property : element.getChildrenByName("Property")) { String key = property.getAttribute("Key", null); String type = property.getAttribute("Type", null); String value = property.getText(); if (type.equals("Int32")) { properties.put(key, Integer.parseInt(value)); } else if (type.equals("String")) { properties.put(key, value); } else if (type.equals("Boolean")) { properties.put(key, value.equalsIgnoreCase("true")); } else { properties.put(key, value); } } } }
@Override public MapProperties getProperties () { if (properties == null) { properties = new MapProperties(); } return properties; }
MapProperties properties = object.getProperties(); if (properties.containsKey("has_text")) { String textToSet= (String) properties.get("has_text"); float x = (Float) properties.get("x"); float y = (Float) properties.get("y"); //Now create you can create the label, you have text(seted in tmx editor) //and x,y are coordinates of the rectangle. }
String atlasFilePath = map.getProperties().get("atlas", String.class); if (atlasFilePath == null) { FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); MapProperties props = tileset.getProperties(); tileset.setName(name); props.put("firstgid", firstgid); props.put("imagesource", imageSource); props.put("imagewidth", imageWidth); props.put("imageheight", imageHeight); props.put("tilewidth", tilewidth); props.put("tileheight", tileheight); props.put("margin", margin); props.put("spacing", spacing); String terrain = tileElement.getAttribute("terrain", null); if (terrain != null) { tile.getProperties().put("terrain", terrain); tile.getProperties().put("probability", probability); tile.getProperties().put("terrain", terrain); tile.getProperties().put("probability", probability);
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; } } } } } }
/** Copy constructor * * @param copy the StaticTiledMapTile to copy. */ public StaticTiledMapTile (StaticTiledMapTile copy) { if (copy.properties != null) { getProperties().putAll(copy.properties); } this.objects = copy.objects; this.textureRegion = copy.textureRegion; this.id = copy.id; }
/** * 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); } } } } } }
String atlasFilePath = map.getProperties().get("atlas", String.class); if (atlasFilePath == null) { FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); MapProperties props = tileset.getProperties(); tileset.setName(name); props.put("firstgid", firstgid); props.put("imagesource", imageSource); props.put("imagewidth", imageWidth); props.put("imageheight", imageHeight); props.put("tilewidth", tilewidth); props.put("tileheight", tileheight); props.put("margin", margin); props.put("spacing", spacing); String terrain = tileElement.getAttribute("terrain", null); if (terrain != null) { tile.getProperties().put("terrain", terrain); tile.getProperties().put("probability", probability); tile.getProperties().put("terrain", terrain); tile.getProperties().put("probability", probability);
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; } } } } } }
/** Copy constructor * * @param copy the StaticTiledMapTile to copy. */ public StaticTiledMapTile (StaticTiledMapTile copy) { if (copy.properties != null) { getProperties().putAll(copy.properties); } this.objects = copy.objects; this.textureRegion = copy.textureRegion; this.id = copy.id; }
/** Returns the object for the given key, casting it to clazz. * @param key the key of the object * @param defaultValue the default value * @param clazz the class of the object * @return the object or the defaultValue if the object is not in the map * @throws ClassCastException if the object with the given key is not of type clazz */ public <T> T get (String key, T defaultValue, Class<T> clazz) { Object object = get(key); return object == null ? defaultValue : (T)object; }
/** * 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); } } } } } }
String atlasFilePath = map.getProperties().get("atlas", String.class); if (atlasFilePath == null) { FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas"); MapProperties props = tileset.getProperties(); tileset.setName(name); props.put("firstgid", firstgid); props.put("imagesource", imageSource); props.put("imagewidth", imageWidth); props.put("imageheight", imageHeight); props.put("tilewidth", tilewidth); props.put("tileheight", tileheight); props.put("margin", margin); props.put("spacing", spacing); String terrain = tileElement.getAttribute("terrain", null); if (terrain != null) { tile.getProperties().put("terrain", terrain); tile.getProperties().put("probability", probability);
private void loadProperties (MapProperties properties, Element element) { if (element.getName().equals("Properties")) { for (Element property : element.getChildrenByName("Property")) { String key = property.getAttribute("Key", null); String type = property.getAttribute("Type", null); String value = property.getText(); if (type.equals("Int32")) { properties.put(key, Integer.parseInt(value)); } else if (type.equals("String")) { properties.put(key, value); } else if (type.equals("Boolean")) { properties.put(key, value.equalsIgnoreCase("true")); } else { properties.put(key, value); } } } }
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 MapProperties getProperties () { if (properties == null) { properties = new MapProperties(); } return properties; }
/** Copy constructor * * @param copy the StaticTiledMapTile to copy. */ public StaticTiledMapTile (StaticTiledMapTile copy) { if (copy.properties != null) { getProperties().putAll(copy.properties); } this.objects = copy.objects; this.textureRegion = copy.textureRegion; this.id = copy.id; }
/** Returns the object for the given key, casting it to clazz. * @param key the key of the object * @param clazz the class of the object * @return the object or null if the object is not in the map * @throws ClassCastException if the object with the given key is not of type clazz */ public <T> T get (String key, Class<T> clazz) { return (T)get(key); }
/** * 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); } } } } } }