Class TmxMap
java.lang.Object
de.gurkenlabs.litiengine.environment.tilemap.xml.CustomPropertyProvider
de.gurkenlabs.litiengine.environment.tilemap.xml.TmxMap
- All Implemented Interfaces:
ICustomPropertyProvider, ILayerList, IMap, Comparable<IMap>
JAXB-bound representation of a Tiled (TMX) map. Implements
IMap so the loaded data integrates seamlessly with the engine's map/environment
API and serves as the in-memory model when the engine reads .tmx files.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFile extension used by Tiled map files.static final intMaximum supported TMX major version.static final intMaximum supported TMX minor version.static final intMinimum supported TMX major version.static final intMinimum supported TMX minor version. -
Constructor Summary
ConstructorsConstructorDescriptionTmxMap()Creates a newTmxMap.TmxMap(IMapOrientation orientation) Creates a newTmxMapwith the given map orientation, defaulting the render order to right-down and the Tiled version to the maximum supported value.Copy constructor for theTmxMapclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anILayerto the Layer list at the given index.voidAdds anILayerto the Layer list.booleanvoidGets the background color of the map.Gets the bounding rectangle of the map in pixels.Returns the list of external tilesets referenced by this map (i.e. tilesets defined in separate.tsxfiles).Gets theIGroupLayers contained in a Layer list.intGets the map height in tiles.intGets the straight edges' length for hexagonal maps.Gets theIImageLayers contained in a Layer list.Returns an unmodifiable snapshot of all map object layers, including layers nested in groups.getName()Gets the display name of this map.intGets the next available layer id, used to assign unique ids to newly created layers.intGets the next object id.Gets the orientation.Gets the coordinates of the parallax origin in pixels.getPath()Gets the source URL the map was loaded from.Gets all render layers in the Layer list.Gets the order in which orthogonal tile coordinates are rendered.Gets the size in pixels.Gets the width and height in tiles.Gets the axis along which hexagonal or staggered rows are offset.Gets whether even or odd indexes are staggered.Gets the Tiled editor version string the map was saved with.intGets the vertical tile size.Gets theITileLayers contained in a Layer list.getTilesetEntry(int gid) Gets the tileset entry referenced by the supplied global tile id.Gets the tilesets.Gets the tile size.intGets the horizontal tile size.doubleGets the version.intgetWidth()Gets the map width in tiles.inthashCode()booleanReturns whether this is an infinite map (i.e. composed of chunks rather than a fixed-size grid).voidremoveLayer(int index) Removes a layer from the Layer list.voidremoveLayer(ILayer layer) Removes anILayerfrom the Layer list.voidsetHeight(int height) Sets the map height in tiles.voidsetHexSideLength(int hexSideLength) Sets the hex side length used for hexagonal maps.voidSets the name.voidsetOrientation(IMapOrientation orientation) Sets the map's orientation.voidSets the source URL the map was loaded from.voidsetRenderOrder(RenderOrder renderorder) Sets the render order used when drawing the map's tile layers.voidsetStaggerAxis(StaggerAxis staggerAxis) Sets the stagger axis used for staggered and hexagonal maps.voidsetStaggerIndex(StaggerIndex staggerIndex) Sets the stagger index used for staggered and hexagonal maps.voidsetTiledVersion(String tiledversion) Sets the Tiled editor version string of this map.voidsetTileHeight(int tileheight) Sets the height of a single tile in pixels.voidsetTileWidth(int tilewidth) Sets the width of a single tile in pixels.voidsetVersion(double version) Sets the TMX format version of this map.voidsetWidth(int width) Sets the map width in tiles.toString()Methods inherited from class CustomPropertyProvider
getBoolValue, getBoolValue, getByteValue, getByteValue, getCharValue, getCharValue, getColorValue, getColorValue, getCommaSeparatedStringValues, getDoubleValue, getDoubleValue, getEnumValue, getEnumValue, getFileValue, getFileValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getMapObjectId, getProperties, getProperty, getShortValue, getShortValue, getStringValue, getStringValue, hasCustomProperty, removeProperty, setProperties, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueMethods inherited from interface ICustomPropertyProvider
getBoolValue, getBoolValue, getByteValue, getByteValue, getCharValue, getCharValue, getColorValue, getColorValue, getCommaSeparatedStringValues, getDoubleValue, getDoubleValue, getEnumValue, getEnumValue, getFileValue, getFileValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getMapObjectId, getProperties, getProperty, getShortValue, getShortValue, getStringValue, getStringValue, hasCustomProperty, removeProperty, setProperties, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueMethods inherited from interface ILayerList
getMapObject, getMapObjectLayer, getMapObjectLayer, getMapObjectLayer, getMapObjects, getMapObjects, getMapObjects, removeMapObject
-
Field Details
-
FILE_EXTENSION
-
MAX_MAJOR
public static final int MAX_MAJORMaximum supported TMX major version.- See Also:
-
MAX_MINOR
public static final int MAX_MINORMaximum supported TMX minor version.- See Also:
-
MIN_MAJOR
public static final int MIN_MAJORMinimum supported TMX major version.- See Also:
-
MIN_MINOR
public static final int MIN_MINORMinimum supported TMX minor version.- See Also:
-
-
Constructor Details
-
TmxMap
public TmxMap()Creates a newTmxMap. Intended for XML deserialization; populated fields will be initialized by JAXB. -
TmxMap
Creates a newTmxMapwith the given map orientation, defaulting the render order to right-down and the Tiled version to the maximum supported value.- Parameters:
orientation- the map orientation
-
TmxMap
Copy constructor for theTmxMapclass. Creates a new instance of theTmxMapclass by copying the properties from the providedTmxMapobject.- Parameters:
original- The originalTmxMapobject to copy from.
-
-
Method Details
-
getImageLayers
Description copied from interface:ILayerListGets theIImageLayers contained in a Layer list.- Specified by:
getImageLayersin interfaceILayerList- Returns:
- a
Listof allIImageLayers
-
getNextObjectId
public int getNextObjectId()Gets the next object id.- Specified by:
getNextObjectIdin interfaceIMap- Returns:
- the next object id
-
getNextLayerId
public int getNextLayerId()Description copied from interface:IMapGets the next available layer id, used to assign unique ids to newly created layers.- Specified by:
getNextLayerIdin interfaceIMap- Returns:
- the next layer id
-
getOrientation
Description copied from interface:IMapGets the orientation.- Specified by:
getOrientationin interfaceIMap- Returns:
- the orientation
-
setOrientation
Sets the map's orientation.- Parameters:
orientation- the orientation; must not benull
-
getPath
-
setPath
Sets the source URL the map was loaded from.- Parameters:
path- the source URL
-
getRenderOrder
Description copied from interface:IMapGets the order in which orthogonal tile coordinates are rendered.- Specified by:
getRenderOrderin interfaceIMap- Returns:
- the render order declared by the map
-
setRenderOrder
Sets the render order used when drawing the map's tile layers.- Parameters:
renderorder- the render order
-
getMapObjectLayers
Returns an unmodifiable snapshot of all map object layers, including layers nested in groups. Changes to the map after this call are visible only in a newly requested snapshot.- Specified by:
getMapObjectLayersin interfaceILayerList- Returns:
- an unmodifiable recursive snapshot of the map object layers
-
getSizeInPixels
Description copied from interface:IMapGets the size in pixels.- Specified by:
getSizeInPixelsin interfaceIMap- Returns:
- the size in pixels
-
getBounds
Description copied from interface:IMapGets the bounding rectangle of the map in pixels. -
getSizeInTiles
Description copied from interface:IMapGets the width and height in tiles.- Specified by:
getSizeInTilesin interfaceIMap- Returns:
- the map size in tiles
-
getTileLayers
Description copied from interface:ILayerListGets theITileLayers contained in a Layer list.- Specified by:
getTileLayersin interfaceILayerList- Returns:
- a
Listof allITileLayers
-
getTilesets
Description copied from interface:IMapGets the tilesets.- Specified by:
getTilesetsin interfaceIMap- Returns:
- the tilesets
-
getTilesetEntry
Description copied from interface:IMapGets the tileset entry referenced by the supplied global tile id.- Specified by:
getTilesetEntryin interfaceIMap- Parameters:
gid- the global tile id- Returns:
- the matching tileset entry, or
nullif no tileset contains the id
-
getTileSize
Description copied from interface:IMapGets the tile size.- Specified by:
getTileSizein interfaceIMap- Returns:
- the tile size
-
getParallaxOrigin
Description copied from interface:IMapGets the coordinates of the parallax origin in pixels.- Specified by:
getParallaxOriginin interfaceIMap- Returns:
- The parallax origin.
-
getTileWidth
public int getTileWidth()Description copied from interface:IMapGets the horizontal tile size.- Specified by:
getTileWidthin interfaceIMap- Returns:
- the horizontal tile size
-
setTileWidth
public void setTileWidth(int tilewidth) Sets the width of a single tile in pixels.- Parameters:
tilewidth- the tile width
-
getTileHeight
public int getTileHeight()Description copied from interface:IMapGets the vertical tile size.- Specified by:
getTileHeightin interfaceIMap- Returns:
- the vertical tile size
-
setTileHeight
public void setTileHeight(int tileheight) Sets the height of a single tile in pixels.- Parameters:
tileheight- the tile height
-
getVersion
public double getVersion()Description copied from interface:IMapGets the version.- Specified by:
getVersionin interfaceIMap- Returns:
- the version
-
setVersion
public void setVersion(double version) Sets the TMX format version of this map.- Parameters:
version- the version
-
getTiledVersion
Description copied from interface:IMapGets the Tiled editor version string the map was saved with.- Specified by:
getTiledVersionin interfaceIMap- Returns:
- the Tiled version string
-
setTiledVersion
Sets the Tiled editor version string of this map.- Parameters:
tiledversion- the Tiled version string
-
getGroupLayers
Description copied from interface:ILayerListGets theIGroupLayers contained in a Layer list.- Specified by:
getGroupLayersin interfaceILayerList- Returns:
- a
Listof allIGroupLayers
-
getName
-
setName
-
getWidth
-
setWidth
public void setWidth(int width) Sets the map width in tiles.- Parameters:
width- the width in tiles
-
getHeight
-
setHeight
public void setHeight(int height) Sets the map height in tiles.- Parameters:
height- the height in tiles
-
getHexSideLength
public int getHexSideLength()Description copied from interface:IMapGets the straight edges' length for hexagonal maps.- Specified by:
getHexSideLengthin interfaceIMap- Returns:
- the hex side length
-
setHexSideLength
public void setHexSideLength(int hexSideLength) Sets the hex side length used for hexagonal maps.- Parameters:
hexSideLength- the hex side length
-
getStaggerAxis
Description copied from interface:IMapGets the axis along which hexagonal or staggered rows are offset.- Specified by:
getStaggerAxisin interfaceIMap- Returns:
- the staggering axis
-
setStaggerAxis
Sets the stagger axis used for staggered and hexagonal maps.- Parameters:
staggerAxis- the stagger axis
-
getStaggerIndex
Description copied from interface:IMapGets whether even or odd indexes are staggered.- Specified by:
getStaggerIndexin interfaceIMap- Returns:
- the staggering index
-
setStaggerIndex
Sets the stagger index used for staggered and hexagonal maps.- Parameters:
staggerIndex- the stagger index
-
finish
- Throws:
TmxException
-
addLayer
Description copied from interface:ILayerListAdds anILayerto the Layer list.- Specified by:
addLayerin interfaceILayerList- Parameters:
layer- the layer to be added
-
addLayer
Description copied from interface:ILayerListAdds anILayerto the Layer list at the given index.- Specified by:
addLayerin interfaceILayerList- Parameters:
index- the indexlayer- the layer to be added
-
removeLayer
Description copied from interface:ILayerListRemoves anILayerfrom the Layer list.- Specified by:
removeLayerin interfaceILayerList- Parameters:
layer- the layer to be removed
-
removeLayer
public void removeLayer(int index) Description copied from interface:ILayerListRemoves a layer from the Layer list.- Specified by:
removeLayerin interfaceILayerList- Parameters:
index- the index of the layer to be removed
-
toString
-
equals
-
hashCode
-
getRenderLayers
Description copied from interface:ILayerListGets all render layers in the Layer list.- Specified by:
getRenderLayersin interfaceILayerList- Returns:
- a List of ILayers
-
getExternalTilesets
-
getBackgroundColor
Description copied from interface:IMapGets the background color of the map.- Specified by:
getBackgroundColorin interfaceIMap- Returns:
- the background color
-
isInfinite
public boolean isInfinite()Description copied from interface:IMapReturns whether this is an infinite map (i.e. composed of chunks rather than a fixed-size grid).- Specified by:
isInfinitein interfaceIMap- Returns:
trueif the map is infinite
-