Class Maps.MapGenerator
java.lang.Object
de.gurkenlabs.litiengine.resources.Maps.MapGenerator
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
Maps
This class provides the API to simplify the generation of map resources from code.
-
Method Summary
Modifier and TypeMethodDescriptionAdds aMapObjectcreated by the specified entity to the map of this instance.add(IMapObject mapObject) Adds the specified map object to the map of this instance.add(IMapObjectLayer layer, IEntity entity) Adds aMapObjectcreated by the specified entity to the map of this instance.add(IMapObjectLayer layer, IMapObject mapObject) Adds the specified map object to the map of this instance.addTileLayer(RenderType renderType, IntBinaryOperator tileCallback) Adds a new tile tile layer to the generated map of this instance.voidclose()It is crucial to call this before using the generated map of this instance.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:
-
addTileLayer
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 aMapObjectcreated by the specified entity to the map of this instance.If no layer has been added yet, a default
MapObjectLayerwill be created by this method.- Parameters:
entity- The entity to be converted to a map object and added to the firstMapObjectLayerof the generated map.- Returns:
- The created map object.
-
add
Adds aMapObjectcreated 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
MapObjectLayerwill be created by this method.- Parameters:
mapObject- The mapObject to be added to the firstMapObjectLayerof 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
finishmethod on the map instance and make sure that the generated map is available over the resources API.- Specified by:
closein interfaceAutoCloseable- See Also:
-