Class Maps.MapGenerator
java.lang.Object
de.gurkenlabs.litiengine.resources.Maps.MapGenerator
- All Implemented Interfaces:
java.lang.AutoCloseable
- Enclosing class:
- Maps
public class Maps.MapGenerator
extends java.lang.Object
implements java.lang.AutoCloseable
This class provides the API to simplify the generation of map resources from code.
Method Summary
Modifier and Type Method Description IMapObject
add(IEntity entity)
Adds aMapObject
created by the specified entity to the map of this instance.IMapObject
add(IMapObject mapObject)
Adds the specified map object to the map of this instance.IMapObject
add(IMapObjectLayer layer, IEntity entity)
Adds aMapObject
created by the specified entity to the map of this instance.IMapObject
add(IMapObjectLayer layer, IMapObject mapObject)
Adds the specified map object to the map of this instance.ITileLayer
addTileLayer(RenderType renderType, java.util.function.IntBinaryOperator tileCallback)
Adds a new tile tile layer to the generated map of this instance.void
close()
It is crucial to call this before using the generated map of this instance.IMap
getMap()
Gets the map generated by this instance.
Method Details
getMap
Gets the map generated by this instance.Make sure this instance is closed before using the map in your game.
- Returns:
- The map generated by this instance.
- See Also:
close()
addTileLayer
public ITileLayer addTileLayer(RenderType renderType, java.util.function.IntBinaryOperator tileCallback)Adds a new tile tile layer to the generated map of this instance. Example for a tileCallback:(x, y) -> { if (x == y) { // draw a diagonal in another tile color return 2; } // fill the entire map with this tile return 1; }
- Parameters:
renderType
- The rendertype of the added layer.tileCallback
- The callback that defines which tile gid will be assigned at the specified x, y grid coordinates.- Returns:
- The newly added tile layer.
add
Adds aMapObject
created by the specified entity to the map of this instance.If no layer has been added yet, a default
MapObjectLayer
will be created by this method.- Parameters:
entity
- The entity to be converted to a map object and added to the firstMapObjectLayer
of the generated map.- Returns:
- The created map object.
add
Adds aMapObject
created by the specified entity to the map of this instance.- Parameters:
layer
- The layer to which the map object will be added.entity
- The entity to be converted to a map object and added to the specifiedMapObjectLayer
.- Returns:
- The created map object.
add
Adds the specified map object to the map of this instance.If no layer has been added yet, a default
MapObjectLayer
will be created by this method.- Parameters:
mapObject
- The mapObject to be added to the firstMapObjectLayer
of the generated map.- Returns:
- The added map object.
add
Adds the specified map object to the map of this instance.- Parameters:
layer
- The layer to which the map object will be added.mapObject
- The mapObject to be added to the specifiedMapObjectLayer
.- Returns:
- The added map object.
close
public void close()It is crucial to call this before using the generated map of this instance.This will call the
finish
method on the map instance and make sure that the generated map is available over the resources API.- Specified by:
close
in interfacejava.lang.AutoCloseable
- See Also:
TmxMap.finish(URL)