List of usage examples for com.badlogic.gdx.maps Map getProperties
public MapProperties getProperties()
From source file:com.cafeitvn.myballgame.screen.Box2DMapObjectParser.java
License:Apache License
/** * creates the given {@link Map Map's} {@link MapObjects} in the given {@link World} * @param world the {@link World} to create the {@link MapObjects} of the given {@link Map} in * @param map the {@link Map} which {@link MapObjects} to create in the given {@link World} * @return the given {@link World} with the parsed {@link MapObjects} of the given {@link Map} created in it *///from w w w. j a v a 2 s. co m public World load(World world, Map map) { if (!ignoreMapUnitScale) unitScale = (Float) getProperty(map.getProperties(), aliases.unitScale, unitScale, Float.class); tileWidth = (Integer) getProperty(map.getProperties(), "tilewidth", tileWidth, Integer.class); tileHeight = (Integer) getProperty(map.getProperties(), "tileheight", tileHeight, Integer.class); for (MapLayer mapLayer : map.getLayers()) load(world, mapLayer); return world; }
From source file:com.cafeitvn.myballgame.screen.Box2DMapObjectParser.java
License:Apache License
/** * @param map the {@link Map} which hierarchy to print * @return a human readable {@link String} containing the hierarchy of the {@link MapObjects} of the given {@link Map} *//*from w w w .j a v a2 s . c o m*/ public String getHierarchy(Map map) { String hierarchy = map.getClass().getSimpleName() + "\n"; Iterator<String> keys = map.getProperties().getKeys(); while (keys.hasNext()) { String key = keys.next(); hierarchy += key + ": " + map.getProperties().get(key) + "\n"; } for (MapLayer layer : map.getLayers()) { hierarchy += "\t" + layer.getName() + " (" + layer.getClass().getSimpleName() + "):\n"; String layerHierarchy = getHierarchy(layer).replace("\n", "\n\t\t"); layerHierarchy = layerHierarchy.endsWith("\n\t\t") ? layerHierarchy.substring(0, layerHierarchy.lastIndexOf("\n\t\t")) : layerHierarchy; hierarchy += !layerHierarchy.equals("") ? "\t\t" + layerHierarchy : layerHierarchy; } return hierarchy; }
From source file:com.indignado.games.smariano.utils.dermetfan.box2d.Box2DMapObjectParser.java
License:Apache License
/** * creates the given {@link com.badlogic.gdx.maps.Map Map's} {@link com.badlogic.gdx.maps.MapObjects} in the given {@link com.badlogic.gdx.physics.box2d.World} * * @param world the {@link com.badlogic.gdx.physics.box2d.World} to create the {@link com.badlogic.gdx.maps.MapObjects} of the given {@link com.badlogic.gdx.maps.Map} in * @param map the {@link com.badlogic.gdx.maps.Map} which {@link com.badlogic.gdx.maps.MapObjects} to create in the given {@link com.badlogic.gdx.physics.box2d.World} * @return the given {@link com.badlogic.gdx.physics.box2d.World} with the parsed {@link com.badlogic.gdx.maps.MapObjects} of the given {@link com.badlogic.gdx.maps.Map} created in it *///from w ww . ja v a 2 s . co m public World load(World world, Map map) { if (!ignoreMapUnitScale) unitScale = getProperty(map.getProperties(), aliases.unitScale, unitScale); box2dObjectFactory.setUnitScale(unitScale); tileWidth = getProperty(map.getProperties(), "tilewidth", (int) tileWidth); tileHeight = getProperty(map.getProperties(), "tileheight", (int) tileHeight); for (MapLayer mapLayer : map.getLayers()) load(world, mapLayer); return world; }
From source file:com.indignado.games.smariano.utils.dermetfan.box2d.Box2DMapObjectParser.java
License:Apache License
/** * @param map the {@link com.badlogic.gdx.maps.Map} which hierarchy to print * @return a human readable {@link String} containing the hierarchy of the {@link com.badlogic.gdx.maps.MapObjects} of the given {@link com.badlogic.gdx.maps.Map} *//* w w w.j av a 2 s .c o m*/ public String getHierarchy(Map map) { String hierarchy = map.getClass().getName() + "\n", key, layerHierarchy; Iterator<String> keys = map.getProperties().getKeys(); while (keys.hasNext()) hierarchy += (key = keys.next()) + ": " + map.getProperties().get(key) + "\n"; for (MapLayer layer : map.getLayers()) { hierarchy += "\t" + layer.getName() + " (" + layer.getClass().getName() + "):\n"; layerHierarchy = getHierarchy(layer).replace("\n", "\n\t\t"); layerHierarchy = layerHierarchy.endsWith("\n\t\t") ? layerHierarchy.substring(0, layerHierarchy.lastIndexOf("\n\t\t")) : layerHierarchy; hierarchy += !layerHierarchy.equals("") ? "\t\t" + layerHierarchy : layerHierarchy; } return hierarchy; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** creates the given {@link Map Map's} {@link MapObjects} in the given {@link World} * @param world the {@link World} to create the {@link MapObjects} of the given {@link Map} in * @param map the {@link Map} which {@link MapObjects} to create in the given {@link World} * @return the given {@link World} with the parsed {@link MapObjects} of the given {@link Map} created in it */ public World load(World world, Map map) { MapProperties oldMapProperties = mapProperties; mapProperties = map.getProperties(); world.setGravity(vec2.set(getProperty(mapProperties, aliases.gravityX, world.getGravity().x), getProperty(mapProperties, aliases.gravityY, world.getGravity().y))); world.setAutoClearForces(getProperty(mapProperties, aliases.autoClearForces, world.getAutoClearForces())); if (!ignoreMapUnitScale) unitScale = getProperty(mapProperties, aliases.unitScale, unitScale); tileWidth = getProperty(mapProperties, aliases.tileWidth, tileWidth); tileHeight = getProperty(mapProperties, aliases.tileHeight, tileHeight); listener.init(this); @SuppressWarnings("unchecked") Array<MapLayer> layers = Pools.obtain(Array.class); layers.clear();/*from ww w . j av a 2 s .c om*/ listener.load(map, layers); for (MapLayer mapLayer : layers) load(world, mapLayer); layers.clear(); Pools.free(layers); mapProperties = oldMapProperties; return world; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.maps.MapUtils.java
License:Apache License
/** @param map the map to represent * @param indent the indentation size (indent is {@code '\t'}) * @return a human-readable hierarchy of the given map and its descendants */ public static String readableHierarchy(Map map, int indent) { String hierarchy = ""; for (int i = 0; i < indent; i++) hierarchy += '\t'; hierarchy += ClassReflection.getSimpleName(map.getClass()) + '\n'; hierarchy += readableHierarchy(map.getProperties(), indent + 1); if (map instanceof TiledMap) hierarchy += readableHierarchy(((TiledMap) map).getTileSets(), indent + 1); hierarchy += readableHierarchy(map.getLayers(), indent + 1); return hierarchy; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.maps.TmxMapWriter.java
License:Apache License
/** @param map the {@link Map} to write in TMX format * @param format the {@link Format} to use * @return this {@link TmxMapWriter} */ public TmxMapWriter tmx(Map map, Format format) throws IOException { append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); append("<!DOCTYPE map SYSTEM \"http://mapeditor.org/dtd/1.0/map.dtd\">\n"); MapProperties props = map.getProperties(); int height = getProperty(props, "height", 0); int tileHeight = getProperty(props, "tileheight", 0); int oldLayerHeight = layerHeight; layerHeight = height * tileHeight;/*from w w w . ja va2s . c o m*/ element("map"); attribute("version", "1.0"); attribute("orientation", getProperty(props, "orientation", "orthogonal")); attribute("width", getProperty(props, "width", 0)); attribute("height", height); attribute("tilewidth", getProperty(props, "tilewidth", 0)); attribute("tileheight", tileHeight); @SuppressWarnings("unchecked") Array<String> excludedKeys = Pools.obtain(Array.class); excludedKeys.clear(); excludedKeys.add("version"); excludedKeys.add("orientation"); excludedKeys.add("width"); excludedKeys.add("height"); excludedKeys.add("tilewidth"); excludedKeys.add("tileheight"); tmx(props, excludedKeys); excludedKeys.clear(); Pools.free(excludedKeys); if (map instanceof TiledMap) tmx(((TiledMap) map).getTileSets()); tmx(map.getLayers(), format); pop(); layerHeight = oldLayerHeight; return this; }
From source file:de.fhkoeln.game.utils.libgdx.maps.MapUtils.java
License:Apache License
/** @param map the map to represent * @param indent the indentation size (indent is {@code '\t'}) * @return a human-readable hierarchy of the given map and its descendants */ public static String readableHierarchy(Map map, int indent) { String hierarchy = ""; for (int i = 0; i < indent; i++) hierarchy += '\t'; hierarchy += map.getClass().getSimpleName() + '\n'; hierarchy += readableHierarchy(map.getProperties(), indent + 1); if (map instanceof TiledMap) hierarchy += readableHierarchy(((TiledMap) map).getTileSets(), indent + 1); hierarchy += readableHierarchy(map.getLayers(), indent + 1); return hierarchy; }
From source file:net.dermetfan.gdx.maps.MapUtils.java
License:Apache License
/** @param map the map to represent * @param indent the indentation size (indent is {@code '\t'}) * @return a human-readable hierarchy of the given map and its descendants */ public static String readableHierarchy(Map map, int indent) { StringBuilder hierarchy = new StringBuilder(); for (int i = 0; i < indent; i++) hierarchy.append('\t'); hierarchy.append(ClassReflection.getSimpleName(map.getClass())).append('\n'); hierarchy.append(readableHierarchy(map.getProperties(), indent + 1)); if (map instanceof TiledMap) hierarchy.append(readableHierarchy(((TiledMap) map).getTileSets(), indent + 1)); hierarchy.append(readableHierarchy(map.getLayers(), indent + 1)); return hierarchy.toString(); }
From source file:net.dermetfan.utils.libgdx.box2d.Box2DMapObjectParser.java
License:Apache License
/** creates the given {@link Map Map's} {@link MapObjects} in the given {@link World} * @param world the {@link World} to create the {@link MapObjects} of the given {@link Map} in * @param map the {@link Map} which {@link MapObjects} to create in the given {@link World} * @return the given {@link World} with the parsed {@link MapObjects} of the given {@link Map} created in it */ public World load(World world, Map map) { MapProperties oldMapProperties = mapProperties; mapProperties = map.getProperties(); world.setGravity(vec2.set(getProperty(mapProperties, aliases.gravityX, world.getGravity().x), getProperty(mapProperties, aliases.gravityY, world.getGravity().y))); world.setAutoClearForces(getProperty(mapProperties, aliases.autoClearForces, world.getAutoClearForces())); if (!ignoreMapUnitScale) unitScale = getProperty(mapProperties, aliases.unitScale, unitScale); tileWidth = getProperty(mapProperties, aliases.tileWidth, tileWidth); tileHeight = getProperty(mapProperties, aliases.tileHeight, tileHeight); for (MapLayer mapLayer : map.getLayers()) load(world, mapLayer);/*from w w w . java2 s .c om*/ mapProperties = oldMapProperties; return world; }