Documentation > Levels > LevelManager

Version: 2.0.4

LevelManager.new(ToDraw)

This function create a new instance of LevelManager.

ToDraw

Indicate if the loaded level should be visible (true or nil) or not (false)

Return

Returns an instance of LevelManager.

LevelManager:load(File)

This function loads a given map file.

File

Path and name of the map to load.

LevelManager:draw(OffsetX, OffsetY, ScaleX, ScaleY)

This function draws the map with a given offset and scale.

OffsetX

.P OffsetY

ScaleX

.P ScaleY

LevelManager:getOpacity(Item)

This function returns the opacity of a given item (layer or object).

Item

Item (layer or object) to get the opacity.

Return

Returns the opacity of the given item (layer or object).

LevelManager:setOpacity(Item, Alpha)

This function set the opacity of the given item (layer or object).

Item

Item (layer or object) on which the opacity is modified.

Alpha

New value of opacity to apply.

LevelManager:restoreOpacity(Item)

This function restores the opacity of the given item (layer or object).

Item

Item (layer or object) on which opacity is restored.

LevelManager:setAllOpacity(Opacity)

This function sets the opacity of all layers and objects to the given value.

Opacity

New value of opacity.

LevelManager:restoreAllOpacity()

This function restores the opacity of all layers and objects.

LevelManager:getLayerByName(Name)

This function returns a layer found by its name. Do not work with a name of a group.

Name

Name of the layer.

Return

Returns a layer found by its name; nil otherwise. Do not work with a name of a group.

LevelManager:getLayersByGroup(GroupName)

This function returns all layers of a group found by its name.

Name

Name of a group.

Return

Returns all layers of a group found by its name.

LevelManager:getObjectByName(Name)

This function returns an object found by its name.

Name

Name of the object to find.

Return

Returns an object found by its name; nil otherwise.

LevelManager:getAllObjectsByType(Type)

This function is a shortcut to retreive all objects of the given type.

Type

Type of object to retreive.

Return

Returns all objects of the given type.

LevelManager:getAllObjectsByShape(Shape)

This function is a shortcu to retreive all objects of the given shape.

Shape

Shape of object to retreive.

Return

Returns all objects of the given shape.

LevelManager:getObjectsInGroup(GroupName)

This function returns all objects of a group retreived by the given name.

GroupName

Name of the group.

Return

Returns all objects of a group retreived by the given name.

LevelManager:getObjectsOnGrid(Row, Col)

This function returns all objects at the given cell coordonates. Row and Col should be inside the grid.

Row

Row of the cell.

Col

Column of the cell.

Return

Returns all objects at the given cell coordonates.

LevelManager:getDimensions()

This function returns the number of columns and rows of the grid and the width (in pixels) and height (in pixels) of each cell.

Return

Returns the number of columns, the number of rows of the grid, the width (in pixels) and height (in pixels) of each cell.

LevelManager:getTileIdAtPos(Layer, Row, Col)

This function returns the tile id at the given coordonate in the given layer.

Layer

Layer to retreive the id.

Row

Row of the cell.

Col

Col of the cell.

Return

Returns the tile id at the given coordonate in the given layer.

LevelManager:setTileIdAtPos(Layer, Row, Col, ImgId, Force)

This function sets the tile id at the given cell coordonate on the given layer by the given id. Must be forced if the new id is 0.

Layer

Layer to modify

Row

Row of the cell.

Col

Col of the cell.

ImgId

Id of the new image inside one of the tilesets.

Force

Force the change of the id. Mandatory if the new id is 0.

LevelManager:restoreTileIdAtPos(Layer, Row, Col)

This function restores the tile id at the given cell coordonate on the given layer.

Layer

Layer to restore.

Row

Row of the cell.

Col

Col of the cell.

LevelManager:setImageId(Object, ImgId)

This function sets the image id of the given object by the given image id if the image id is valid.

Object

Object to set the image.

ImgId

New image id for the object.

LevelManager:restoreObjectImageId(Object)

This function restores the image id of the given object.

Object

Object to restore.

LevelManager:convertRowColToCoord(Row, Col)

This function converts the given cell coordonate to X,Y coordonate.

Row

Row of the cell.

Col

Column of the cell.

Return

Returns the X,Y coordonate from the cell coordonate.

LevelManager:convertCoordToRowCol(X, Y)

This function converts a X,Y coordonate to cell coordonate.

X

Position on the X-axis.

Y

Position on the Y-axis.

Return

Returns the row and column of the cell at the given X,Y coordonate.

LevelManager:reload()

This function reloads all datas of all layers and objects.

LevelManager:resetObjects()

This function restore all objects at their original values.

LevelManager:toString(NoTitle)

This function display all variables containing in the current LevelManager instance (tables and functions are excluded).

NoTitle

Indicates if the title must be displayed (false) or not (true).