1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 09:09:30 +00:00
ubiquitousse/docs/modules/ldtk.html

1606 lines
32 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
<title>Ubiquitousse reference</title>
<link rel="stylesheet" href="../ldoc_new.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"></div>
<div id="product_name"><big><b></b></big></div>
<div id="product_description"></div>
</div> <!-- id="product" -->
<div id="main">
<!-- Menu -->
<div id="navigation">
<br/>
<h1>Ubiquitousse</h1>
<ul>
<li><a href="../index.html">Index</a></li>
</ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tileset_objects">Tileset objects </a></li>
<li><a href="#Layer_objects">Layer objects </a></li>
<li><a href="#Tile_objects">Tile objects </a></li>
<li><a href="#IntTile_objects">IntTile objects </a></li>
<li><a href="#Entity_objects">Entity objects </a></li>
<li><a href="#Level_objects">Level objects </a></li>
<li><a href="#Project_objects">Project objects </a></li>
</ul>
<h2>Modules</h2>
<ul class="nowrap">
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><strong>ldtk</strong></li>
<li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/asset.html">asset</a></li>
</ul>
<h2>Topics</h2>
<ul class="">
<li><a href="../topics/README.md.html">README</a></li>
<li><a href="../topics/LICENSE.html">LICENSE</a></li>
</ul>
</div>
<div id="content">
<h1>Module <code>ldtk</code></h1>
<p><a href="https://ldtk.io/">LDtk</a> level importer for LÖVE.</p>
<p> Support most LDtk features, and allow easy usage in LÖVE projects.</p>
<p> Every unit is in pixel in the API unless written otherwise.</p>
<p> This modules returns a single function, <a href="../modules/ldtk.html#LDtk">LDtk</a>(path).</p>
<p> Requires LÖVE <code>love.graphics</code> (drawing Image, SpriteBatch, Quad).</p>
<h3>Usage:</h3>
<ul>
<pre class="example">local ldtk = require(&quot;ubiquitousse.ldtk&quot;)
-- load ldtk project file
local project = ltdk(&quot;example.ldtk&quot;)
-- can define callbacks when loading: for example to setup entities defined in LDtk
local callbacks = {
onAddEntity = function(entity)
-- handle entity...
end
}
-- load every level, with callbacks
for _, lvl in ipairs(project.levels) do lvl:load(callbacks) end
function love.draw()
-- draw every level
for _, lvl in ipairs(project.levels) do lvl:draw() end
end
</pre>
</ul>
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#LDtk">LDtk (path)</a></td>
<td class="summary">Load a LDtk project.</td>
</tr>
</table>
<h2><a href="#Tileset_objects">Tileset objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Tileset.image">Tileset.image</a></td>
<td class="summary">The tileset LÖVE image object.</td>
</tr>
</table>
<h2><a href="#Layer_objects">Layer objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Layer:draw">Layer:draw ()</a></td>
<td class="summary">Draw the current layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.level">Layer.level</a></td>
<td class="summary"><a href="../modules/ldtk.html#Level_objects">Level</a> this layer belongs to.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.identifier">Layer.identifier</a></td>
<td class="summary">The layer name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.type">Layer.type</a></td>
<td class="summary">Type of layer: IntGrid, Entities, Tiles or AutoLayer (string).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.visible">Layer.visible</a></td>
<td class="summary">Whether the layer is visible or not.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.opacity">Layer.opacity</a></td>
<td class="summary">The layer opacity (0-1).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.order">Layer.order</a></td>
<td class="summary">The layer order: smaller order means it is on top.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.offsetX">Layer.offsetX</a></td>
<td class="summary">X position of the layer relative to the level.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.offsetY">Layer.offsetY</a></td>
<td class="summary">Y position of the layer relative to the level.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.gridSize">Layer.gridSize</a></td>
<td class="summary">Size of the grid on this layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.gridWidth">Layer.gridWidth</a></td>
<td class="summary">Width of the layer, in grid units.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.gridHeight">Layer.gridHeight</a></td>
<td class="summary">Height of the layer, in grid units.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.entities">Layer.entities</a></td>
<td class="summary"><em>(Entities layer only)</em> List of <a href="../modules/ldtk.html#Entity_objects">Entity</a> in the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.tiles">Layer.tiles</a></td>
<td class="summary"><em>(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)</em> List of <a href="../modules/ldtk.html#Tile_objects">Tile</a>s in the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.tileset">Layer.tileset</a></td>
<td class="summary"><em>(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)</em> <a href="../modules/ldtk.html#Tileset_objects">Tileset</a> object associated with the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.spritebatch">Layer.spritebatch</a></td>
<td class="summary"><em>(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)</em> <a href="https://love2d.org/wiki/SpriteBatch">LÖVE SpriteBatch</a> containing the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Layer.intTiles">Layer.intTiles</a></td>
<td class="summary"><em>(IntGrid without AutoLayer rules layer only)</em> list of <a href="../modules/ldtk.html#IntTile_objects">IntTile</a>s in the layer.</td>
</tr>
</table>
<h2><a href="#Tile_objects">Tile objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Tile.layer">Tile.layer</a></td>
<td class="summary">Layer the tile belongs to.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.x">Tile.x</a></td>
<td class="summary">X position of the tile relative to the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.y">Tile.y</a></td>
<td class="summary">Y position of the tile relative to the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.flipX">Tile.flipX</a></td>
<td class="summary">Whether the tile is flipped horizontally.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.flipY">Tile.flipY</a></td>
<td class="summary">Whether the tile is flipped vertically.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.tags">Tile.tags</a></td>
<td class="summary">Tags associated with the tile: can be used either as a list of tags or a map of activated tags tags[name] == true.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.data">Tile.data</a></td>
<td class="summary">Custom data associated with the tile, if any.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Tile.quad">Tile.quad</a></td>
<td class="summary">Quad associated with the tile (relative to the layer&rsquo;s tileset).</td>
</tr>
</table>
<h2><a href="#IntTile_objects">IntTile objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#IntTile.layer">IntTile.layer</a></td>
<td class="summary">Layer the IntTile belongs to.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#IntTile.x">IntTile.x</a></td>
<td class="summary">X position of the IntTile relative to the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#IntTile.y">IntTile.y</a></td>
<td class="summary">Y position of the IntTile relative to the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#IntTile.identifier">IntTile.identifier</a></td>
<td class="summary">Name of the IntTile.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#IntTile.value">IntTile.value</a></td>
<td class="summary">Integer value of the IntTile.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#IntTile.color">IntTile.color</a></td>
<td class="summary">Color of the IntTile.</td>
</tr>
</table>
<h2><a href="#Entity_objects">Entity objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Entity.layer">Entity.layer</a></td>
<td class="summary"><a href="../modules/ldtk.html#Layer_objects">Layer</a> this entity belongs to.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.identifier">Entity.identifier</a></td>
<td class="summary">The entity name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.x">Entity.x</a></td>
<td class="summary">X position of the entity relative to the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.y">Entity.y</a></td>
<td class="summary">Y position of the entity relative to the layer.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.width">Entity.width</a></td>
<td class="summary">The entity width.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.height">Entity.height</a></td>
<td class="summary">The entity height.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.sx">Entity.sx</a></td>
<td class="summary">Scale factor on x axis relative to original entity size.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.sy">Entity.sy</a></td>
<td class="summary">Scale factor on y axis relative to original entity size.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.pivotX">Entity.pivotX</a></td>
<td class="summary">The entity pivot point x position relative to the entity.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.pivotY">Entity.pivotY</a></td>
<td class="summary">The entity pivot point x position relative to the entity.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.color">Entity.color</a></td>
<td class="summary">Entity color.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.tile">Entity.tile</a></td>
<td class="summary">Entity tile, if any.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity.fields">Entity.fields</a></td>
<td class="summary">Map of custom fields of the entity.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Entity:draw">Entity:draw ()</a></td>
<td class="summary">Called for the entity when drawing the associated entity layer (you will likely want to redefine it).</td>
</tr>
</table>
<h2><a href="#Level_objects">Level objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Level:draw">Level:draw ()</a></td>
<td class="summary">Draw this level.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level:load">Level:load ([, callbacks])</a></td>
<td class="summary">Load the level.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level:unload">Level:unload ([, callbacks])</a></td>
<td class="summary">Unload the level.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.project">Level.project</a></td>
<td class="summary"><a href="../modules/ldtk.html#Project_objects">Project</a> this level belongs to.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.loaded">Level.loaded</a></td>
<td class="summary">Whether this level is currently loaded or not (boolean).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.identifier">Level.identifier</a></td>
<td class="summary">The level name (string).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.x">Level.x</a></td>
<td class="summary">The level x position (number).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.y">Level.y</a></td>
<td class="summary">The level y position (number).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.width">Level.width</a></td>
<td class="summary">The level width (number).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.height">Level.height</a></td>
<td class="summary">The level height (number).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.fields">Level.fields</a></td>
<td class="summary">Map of custom fields of the level (table).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level.layers">Level.layers</a></td>
<td class="summary">List of <a href="../modules/ldtk.html#Layer_objects">Layer</a>s in the level (table).</td>
</tr>
</table>
<h2><a href="#Project_objects">Project objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#Project.levels">Project.levels</a></td>
<td class="summary">List of <a href="../modules/ldtk.html#Level_objects">Level</a>s in this project.</td>
</tr>
</table>
<br/>
<br/>
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
<dl class="function">
<dt>
<a name = "LDtk"></a>
<strong>LDtk (path)</strong>
</dt>
<dd>
Load a LDtk project.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">path</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
to LDtk project file (.ldtk)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/ldtk.html#Project_objects">Project</a></span>
the loaded LDtk project
</ol>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Tileset_objects"></a>Tileset objects </h2>
<div class="section-description">
Tileset object.
Stores the image associated with the tileset; can be shared among several layers and levels.
</div>
<dl class="function">
<dt>
<a name = "Tileset.image"></a>
<strong>Tileset.image</strong>
</dt>
<dd>
The tileset LÖVE image object.
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Layer_objects"></a>Layer objects </h2>
<div class="section-description">
Layer object. </p>
<p> Part of a <a href="../modules/ldtk.html#Level_objects">Level</a>.
</div>
<dl class="function">
<dt>
<a name = "Layer:draw"></a>
<strong>Layer:draw ()</strong>
</dt>
<dd>
Draw the current layer.
Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
<h3>Requires:</h3>
<ul>
love
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.level"></a>
<strong>Layer.level</strong>
</dt>
<dd>
<a href="../modules/ldtk.html#Level_objects">Level</a> this layer belongs to.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.identifier"></a>
<strong>Layer.identifier</strong>
</dt>
<dd>
The layer name.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.type"></a>
<strong>Layer.type</strong>
</dt>
<dd>
Type of layer: IntGrid, Entities, Tiles or AutoLayer (string).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.visible"></a>
<strong>Layer.visible</strong>
</dt>
<dd>
Whether the layer is visible or not.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.opacity"></a>
<strong>Layer.opacity</strong>
</dt>
<dd>
The layer opacity (0-1).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.order"></a>
<strong>Layer.order</strong>
</dt>
<dd>
The layer order: smaller order means it is on top.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.offsetX"></a>
<strong>Layer.offsetX</strong>
</dt>
<dd>
X position of the layer relative to the level.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.offsetY"></a>
<strong>Layer.offsetY</strong>
</dt>
<dd>
Y position of the layer relative to the level.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.gridSize"></a>
<strong>Layer.gridSize</strong>
</dt>
<dd>
Size of the grid on this layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.gridWidth"></a>
<strong>Layer.gridWidth</strong>
</dt>
<dd>
Width of the layer, in grid units.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.gridHeight"></a>
<strong>Layer.gridHeight</strong>
</dt>
<dd>
Height of the layer, in grid units.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.entities"></a>
<strong>Layer.entities</strong>
</dt>
<dd>
<em>(Entities layer only)</em> List of <a href="../modules/ldtk.html#Entity_objects">Entity</a> in the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.tiles"></a>
<strong>Layer.tiles</strong>
</dt>
<dd>
<em>(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)</em> List of <a href="../modules/ldtk.html#Tile_objects">Tile</a>s in the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.tileset"></a>
<strong>Layer.tileset</strong>
</dt>
<dd>
<em>(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)</em> <a href="../modules/ldtk.html#Tileset_objects">Tileset</a> object associated with the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.spritebatch"></a>
<strong>Layer.spritebatch</strong>
</dt>
<dd>
<em>(Tiles, AutoLayer, or IntGrid with AutoLayer rules layers only)</em> <a href="https://love2d.org/wiki/SpriteBatch">LÖVE SpriteBatch</a> containing the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Layer.intTiles"></a>
<strong>Layer.intTiles</strong>
</dt>
<dd>
<em>(IntGrid without AutoLayer rules layer only)</em> list of <a href="../modules/ldtk.html#IntTile_objects">IntTile</a>s in the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Tile_objects"></a>Tile objects </h2>
<div class="section-description">
Tile object. </p>
<p> This represent the tiles from a Tiles, AutoLayer or IntGrid with AutoLayer rules layer.</p>
<p> Can be retrived from the <a href="../modules/ldtk.html#Layer.tiles">tiles</a> list or <code>onAddTile</code> level load callback.
</div>
<dl class="function">
<dt>
<a name = "Tile.layer"></a>
<strong>Tile.layer</strong>
</dt>
<dd>
Layer the tile belongs to.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.x"></a>
<strong>Tile.x</strong>
</dt>
<dd>
X position of the tile relative to the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.y"></a>
<strong>Tile.y</strong>
</dt>
<dd>
Y position of the tile relative to the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.flipX"></a>
<strong>Tile.flipX</strong>
</dt>
<dd>
Whether the tile is flipped horizontally.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.flipY"></a>
<strong>Tile.flipY</strong>
</dt>
<dd>
Whether the tile is flipped vertically.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.tags"></a>
<strong>Tile.tags</strong>
</dt>
<dd>
Tags associated with the tile: can be used either as a list of tags or a map of activated tags tags[name] == true.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.data"></a>
<strong>Tile.data</strong>
</dt>
<dd>
Custom data associated with the tile, if any.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Tile.quad"></a>
<strong>Tile.quad</strong>
</dt>
<dd>
Quad associated with the tile (relative to the layer&rsquo;s tileset).
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="IntTile_objects"></a>IntTile objects </h2>
<div class="section-description">
IntTile object. </p>
<p> This represent the tiles from a IntGrid without AutoLayer rules layer.</p>
<p> Can be retrived from the <a href="../modules/ldtk.html#Layer.intTiles">intTiles</a> list or <code>onAddIntTile</code> level load callback.
</div>
<dl class="function">
<dt>
<a name = "IntTile.layer"></a>
<strong>IntTile.layer</strong>
</dt>
<dd>
Layer the IntTile belongs to.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "IntTile.x"></a>
<strong>IntTile.x</strong>
</dt>
<dd>
X position of the IntTile relative to the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "IntTile.y"></a>
<strong>IntTile.y</strong>
</dt>
<dd>
Y position of the IntTile relative to the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "IntTile.identifier"></a>
<strong>IntTile.identifier</strong>
</dt>
<dd>
Name of the IntTile.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "IntTile.value"></a>
<strong>IntTile.value</strong>
</dt>
<dd>
Integer value of the IntTile.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "IntTile.color"></a>
<strong>IntTile.color</strong>
</dt>
<dd>
Color of the IntTile.
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Entity_objects"></a>Entity objects </h2>
<div class="section-description">
Entity object. </p>
<p> This represent an entity from an Entities layer.</p>
<p> Can be retrived from the <a href="../modules/ldtk.html#Layer.entities">entities</a> list or <code>onAddEntity</code> level load callback.
</div>
<dl class="function">
<dt>
<a name = "Entity.layer"></a>
<strong>Entity.layer</strong>
</dt>
<dd>
<a href="../modules/ldtk.html#Layer_objects">Layer</a> this entity belongs to.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.identifier"></a>
<strong>Entity.identifier</strong>
</dt>
<dd>
The entity name.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.x"></a>
<strong>Entity.x</strong>
</dt>
<dd>
X position of the entity relative to the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.y"></a>
<strong>Entity.y</strong>
</dt>
<dd>
Y position of the entity relative to the layer.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.width"></a>
<strong>Entity.width</strong>
</dt>
<dd>
The entity width.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.height"></a>
<strong>Entity.height</strong>
</dt>
<dd>
The entity height.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.sx"></a>
<strong>Entity.sx</strong>
</dt>
<dd>
Scale factor on x axis relative to original entity size.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.sy"></a>
<strong>Entity.sy</strong>
</dt>
<dd>
Scale factor on y axis relative to original entity size.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.pivotX"></a>
<strong>Entity.pivotX</strong>
</dt>
<dd>
The entity pivot point x position relative to the entity.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.pivotY"></a>
<strong>Entity.pivotY</strong>
</dt>
<dd>
The entity pivot point x position relative to the entity.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.color"></a>
<strong>Entity.color</strong>
</dt>
<dd>
Entity color.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.tile"></a>
<strong>Entity.tile</strong>
</dt>
<dd>
Entity tile, if any. Is a table { tileset = associated tileset object, quad = associated quad }.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity.fields"></a>
<strong>Entity.fields</strong>
</dt>
<dd>
Map of custom fields of the entity.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Entity:draw"></a>
<strong>Entity:draw ()</strong>
</dt>
<dd>
Called for the entity when drawing the associated entity layer (you will likely want to redefine it). </p>
<p> By default, this draws the tile associated with the entity if there is one, or a rectangle around the entity position otherwise.
<h3>Requires:</h3>
<ul>
love
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Level_objects"></a>Level objects </h2>
<div class="section-description">
Level object. </p>
<p> Levels are not automatically loaded in order to not waste ressources if your project is large; so before drawing or operating on a level, you will need to call its <a href="../modules/ldtk.html#Level:load">Level:load</a> method.</p>
<p> Part of a <a href="../modules/ldtk.html#Project_objects">Project</a>.
</div>
<dl class="function">
<dt>
<a name = "Level:draw"></a>
<strong>Level:draw ()</strong>
</dt>
<dd>
Draw this level.
Assumes we are currently in world coordinates (i.e. world top-left is at 0,0).
The level must be loaded.
Will draw the eventual backgrounds and all the layers in the level.
<h3>Requires:</h3>
<ul>
love
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level:load"></a>
<strong>Level:load ([, callbacks])</strong>
</dt>
<dd>
Load the level.
Will load every layer in the level and the associated images.</p>
<p> You can optionally specify some callbacks for the loading process:</p>
<ul>
<li><code>onAddLayer(layer)</code> will be called for every new layer loaded, with the <a href="../modules/ldtk.html#Layer_objects">Layer</a> as sole argument</li>
<li><code>onAddTile(tile)</code> will be called for every new tile loaded, with the <a href="../modules/ldtk.html#Tile_objects">Tile</a> as sole argument</li>
<li><code>onAddIntTile(tile)</code> will be called for every new IntGrid tile loaded, with the <a href="../modules/ldtk.html#IntTile_objects">IntTile</a> as sole argument</li>
<li><code>onAddEntity(entity)</code> will be called for every new entity loaded, with the <a href="../modules/ldtk.html#Entity_objects">Entity</a> as sole argument</li>
</ul>
<p> These callbacks should allow you to capture all the important elements needed to use the level, so you can hopefully
integrate it into your current game engine easily.
<h3>Requires:</h3>
<ul>
love
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callbacks</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Level:unload"></a>
<strong>Level:unload ([, callbacks])</strong>
</dt>
<dd>
<p>Unload the level.
Images loaded by the level will be freed on the next garbage collection cycle.</p>
<p> You can optionally specify some callbacks for the unloading process:</p>
<ul>
<li><code>onAddLayer(layer)</code> will be called for every new layer unloaded, with the <a href="../modules/ldtk.html#Layer_objects">Layer</a> as sole argument</li>
<li><code>onAddTile(tile)</code> will be called for every new tile unloaded, with the <a href="../modules/ldtk.html#Tile_objects">Tile</a> as sole argument</li>
<li><code>onAddIntTile(tile)</code> will be called for every new IntGrid tile unloaded, with the <a href="../modules/ldtk.html#IntTile_objects">IntTile</a> as sole argument</li>
<li><code>onAddEntity(entity)</code> will be called for every new entity unloaded, with the <a href="../modules/ldtk.html#Entity_objects">Entity</a> as sole argument</li>
</ul>
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">callbacks</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
(<em>optional</em>)
</li>
</ul>
</dd>
<dt>
<a name = "Level.project"></a>
<strong>Level.project</strong>
</dt>
<dd>
<a href="../modules/ldtk.html#Project_objects">Project</a> this level belongs to.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.loaded"></a>
<strong>Level.loaded</strong>
</dt>
<dd>
Whether this level is currently loaded or not (boolean).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.identifier"></a>
<strong>Level.identifier</strong>
</dt>
<dd>
The level name (string).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.x"></a>
<strong>Level.x</strong>
</dt>
<dd>
The level x position (number).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.y"></a>
<strong>Level.y</strong>
</dt>
<dd>
The level y position (number).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.width"></a>
<strong>Level.width</strong>
</dt>
<dd>
The level width (number).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.height"></a>
<strong>Level.height</strong>
</dt>
<dd>
The level height (number).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.fields"></a>
<strong>Level.fields</strong>
</dt>
<dd>
Map of custom fields of the level (table).
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "Level.layers"></a>
<strong>Level.layers</strong>
</dt>
<dd>
List of <a href="../modules/ldtk.html#Layer_objects">Layer</a>s in the level (table).
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="Project_objects"></a>Project objects </h2>
<div class="section-description">
Project object. </p>
<p> Returned by <a href="../modules/ldtk.html#LDtk">LDtk</a>.
</div>
<dl class="function">
<dt>
<a name = "Project.levels"></a>
<strong>Project.levels</strong>
</dt>
<dd>
List of <a href="../modules/ldtk.html#Level_objects">Level</a>s in this project.
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-25 17:10:15 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>