Package net.dermetfan.gdx.maps
Class MapUtils
java.lang.Object
net.dermetfan.gdx.maps.MapUtils
public class MapUtils
extends java.lang.Object
provides useful methods for dealing with maps
-
Constructor Summary
Constructors Constructor Description MapUtils() -
Method Summary
Modifier and Type Method Description static <T> TfindProperty(java.lang.String key, T defaultValue, com.badlogic.gdx.maps.MapProperties... properties)Finds a property in an array ofMapProperties.static <T> TgetProperty(com.badlogic.gdx.maps.MapProperties properties, java.lang.String key, T defaultValue)Makes sure the return value is of the desired type (null-safe).static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.Map map)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.MapLayer layer, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.MapLayers layers, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.MapObject object, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.MapObjects objects, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.Map map, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.MapProperties properties, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.tiled.TiledMapTile tile, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.tiled.TiledMapTileSet set, int indent)static java.lang.StringreadableHierarchy(com.badlogic.gdx.maps.tiled.TiledMapTileSets sets, int indent)static com.badlogic.gdx.math.Vector2size(com.badlogic.gdx.maps.tiled.TiledMap map)sets the given Vector2 to the max width and height of alltile layersof the given mapstatic com.badlogic.gdx.math.Vector2toIsometricGridPoint(float x, float y, float cellWidth, float cellHeight)static com.badlogic.gdx.math.Vector2toIsometricGridPoint(com.badlogic.gdx.math.Vector2 point, float cellWidth, float cellHeight)converts point to its coordinates on an isometric gridstatic com.badlogic.gdx.math.Vector3toIsometricGridPoint(com.badlogic.gdx.math.Vector3 point, float cellWidth, float cellHeight)static com.badlogic.gdx.maps.tiled.TiledMapTile[]toTiledMapTileArray(com.badlogic.gdx.maps.tiled.TiledMapTileSet tiles)creates an array of TiledMapTiles from aTiledMapTileSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
MapUtils
public MapUtils()
-
-
Method Details
-
findProperty
public static <T> T findProperty(java.lang.String key, T defaultValue, com.badlogic.gdx.maps.MapProperties... properties)Finds a property in an array ofMapProperties. If multipleMapPropertiescontain the value, the later given one's value is returned.- Type Parameters:
T- the type of the value- Parameters:
key- the keydefaultValue- the default valueproperties- theMapPropertiesto search- Returns:
- the last found value or defaultValue
-
getProperty
public static <T> T getProperty(com.badlogic.gdx.maps.MapProperties properties, java.lang.String key, T defaultValue)Makes sure the return value is of the desired type (null-safe). If the value of the property is not of the desired type, it will be parsed.- Parameters:
properties- theMapPropertiesto get the value fromkey- the key of the propertydefaultValue- the value to return in case the value was null or an empty String or couldn't be returned- Returns:
- the key's value as the type of defaultValue
-
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.Map map) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.Map map, int indent)- Parameters:
map- the map to representindent- the indentation size (indent is'\t')- Returns:
- a human-readable hierarchy of the given map and its descendants
-
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.tiled.TiledMapTileSets sets, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.tiled.TiledMapTileSet set, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.tiled.TiledMapTile tile, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.MapLayers layers, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.MapLayer layer, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.MapObjects objects, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.MapObject object, int indent) -
readableHierarchy
public static java.lang.String readableHierarchy(com.badlogic.gdx.maps.MapProperties properties, int indent) -
toTiledMapTileArray
public static com.badlogic.gdx.maps.tiled.TiledMapTile[] toTiledMapTileArray(com.badlogic.gdx.maps.tiled.TiledMapTileSet tiles)creates an array of TiledMapTiles from aTiledMapTileSet- Parameters:
tiles- theTiledMapTileSetto create an array from- Returns:
- the array of TiledMapTiles
-
toIsometricGridPoint
public static com.badlogic.gdx.math.Vector2 toIsometricGridPoint(com.badlogic.gdx.math.Vector2 point, float cellWidth, float cellHeight)converts point to its coordinates on an isometric grid- Parameters:
point- the point to convertcellWidth- the width of the grid cellscellHeight- the height of the grid cells- Returns:
- the given point converted to its coordinates on an isometric grid
-
toIsometricGridPoint
public static com.badlogic.gdx.math.Vector2 toIsometricGridPoint(float x, float y, float cellWidth, float cellHeight) -
toIsometricGridPoint
public static com.badlogic.gdx.math.Vector3 toIsometricGridPoint(com.badlogic.gdx.math.Vector3 point, float cellWidth, float cellHeight) -
size
public static com.badlogic.gdx.math.Vector2 size(com.badlogic.gdx.maps.tiled.TiledMap map)sets the given Vector2 to the max width and height of alltile layersof the given map- Parameters:
map- the map to measure- Returns:
- the given Vector2 representing the map size
-