mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-27 09:09:30 +00:00
ldtk: rename Layer.offsetX/Y to Layer.x/y, add Level:drawBackground
This commit is contained in:
parent
86373c98de
commit
f78499e891
12 changed files with 70 additions and 35 deletions
|
|
@ -108,7 +108,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1626,7 +1626,7 @@ its sibling systems (i.e. completely stop the propagation of the event).</li>
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -206,11 +206,11 @@ end
|
|||
<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="name" nowrap><a href="#Layer.x">Layer.x</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="name" nowrap><a href="#Layer.y">Layer.y</a></td>
|
||||
<td class="summary">Y position of the layer relative to the level.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -312,7 +312,11 @@ end
|
|||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Level:draw">Level:draw ()</a></td>
|
||||
<td class="summary">Draw this level.</td>
|
||||
<td class="summary">Draw this level (background and layers).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Level:drawBackground">Level:drawBackground ()</a></td>
|
||||
<td class="summary">Draw this level background.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#Level:load">Level:load ([, callbacks])</a></td>
|
||||
|
|
@ -909,8 +913,8 @@ end
|
|||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "Layer.offsetX"></a>
|
||||
<strong>Layer.offsetX</strong>
|
||||
<a name = "Layer.x"></a>
|
||||
<strong>Layer.x</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
X position of the layer relative to the level.
|
||||
|
|
@ -930,8 +934,8 @@ end
|
|||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "Layer.offsetY"></a>
|
||||
<strong>Layer.offsetY</strong>
|
||||
<a name = "Layer.y"></a>
|
||||
<strong>Layer.y</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Y position of the layer relative to the level.
|
||||
|
|
@ -1458,7 +1462,7 @@ end
|
|||
<strong>Level:draw ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Draw this level.
|
||||
Draw this level (background and layers).
|
||||
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.
|
||||
|
|
@ -1476,6 +1480,29 @@ end
|
|||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "Level:drawBackground"></a>
|
||||
<strong>Level:drawBackground ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Draw this level background.
|
||||
Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
|
||||
The level must be loaded.
|
||||
|
||||
<h3>Requires:</h3>
|
||||
<ul>
|
||||
love
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "Level:load"></a>
|
||||
|
|
@ -1754,7 +1781,7 @@ end
|
|||
Level background. </p>
|
||||
|
||||
<p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code>
|
||||
where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Level.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a> are the top-left position,
|
||||
where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Entity.y">y</a> are the top-left position,
|
||||
and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors.
|
||||
|
||||
</ul>
|
||||
|
|
@ -1829,7 +1856,7 @@ end
|
|||
<li>Enum are converted into a Lua string giving the currently selected enum value.</li>
|
||||
<li>Filepath are converted into a Lua string giving the file path.</li>
|
||||
<li>Arrays are converted into a Lua table with the elements in it as a list.</li>
|
||||
<li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Level.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a>: <code>{ x=number, y=number }</code>.</li>
|
||||
<li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Entity.y">y</a>: <code>{ x=number, y=number }</code>.</li>
|
||||
<li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li>
|
||||
</ul>
|
||||
|
||||
|
|
@ -1855,7 +1882,7 @@ end
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -702,7 +702,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1153,7 +1153,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
</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-27 13:15:05 </i>
|
||||
<i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ let layer_mt = {
|
|||
draw = :()
|
||||
if @visible then
|
||||
lg.push()
|
||||
lg.translate(@offsetX, @offsetY)
|
||||
lg.translate(@x, @y)
|
||||
if @spritebatch then
|
||||
lg.setColor(1, 1, 1, @opacity)
|
||||
lg.draw(@spritebatch)
|
||||
|
|
@ -211,10 +211,10 @@ let layer_mt = {
|
|||
order = order,
|
||||
--- X position of the layer relative to the level.
|
||||
-- @ftype number
|
||||
offsetX = layer.__pxTotalOffsetX,
|
||||
x = layer.__pxTotalOffsetX,
|
||||
--- Y position of the layer relative to the level.
|
||||
-- @ftype number
|
||||
offsetY = layer.__pxTotalOffsetY,
|
||||
y = layer.__pxTotalOffsetY,
|
||||
--- Size of the grid on this layer.
|
||||
-- @ftype number
|
||||
gridSize = gridSize,
|
||||
|
|
@ -441,7 +441,7 @@ layer_mt.__index = layer_mt
|
|||
--
|
||||
-- @type Level
|
||||
let level_mt = {
|
||||
--- Draw this level.
|
||||
--- Draw this level (background and layers).
|
||||
-- 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.
|
||||
|
|
@ -450,6 +450,19 @@ let level_mt = {
|
|||
assert(@loaded == true, "level not loaded")
|
||||
lg.push()
|
||||
lg.translate(@x, @y)
|
||||
@drawBackground()
|
||||
-- layers
|
||||
for _, l in ipairs(@layers) do
|
||||
l:draw()
|
||||
end
|
||||
lg.pop()
|
||||
end,
|
||||
--- Draw this level background.
|
||||
-- Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
|
||||
-- The level must be loaded.
|
||||
-- @require love
|
||||
drawBackground = :()
|
||||
assert(@loaded == true, "level not loaded")
|
||||
-- background color
|
||||
lg.setColor(@background.color)
|
||||
lg.rectangle("fill", 0, 0, @width, @height)
|
||||
|
|
@ -459,11 +472,6 @@ let level_mt = {
|
|||
if bgImage then
|
||||
lg.draw(bgImage.image, bgImage.quad, bgImage.x, bgImage.y, 0, bgImage.sx, bgImage.sy)
|
||||
end
|
||||
-- layers
|
||||
for _, l in ipairs(@layers) do
|
||||
l:draw()
|
||||
end
|
||||
lg.pop()
|
||||
end,
|
||||
|
||||
--- Load the level.
|
||||
|
|
@ -589,7 +597,7 @@ level_mt.__index = level_mt
|
|||
-- @type Project
|
||||
let project_mt = {
|
||||
_init = (project, directory)
|
||||
assert(project.jsonVersion == "0.9.3", "map made for LDtk version %s":format(project.jsonVersion))
|
||||
assert(project.jsonVersion == "0.9.3", "the map was made with LDtk version %s but the importer is made for 0.9.3":format(project.jsonVersion))
|
||||
let t = {
|
||||
--- List of `Level`s in this project.
|
||||
-- @ftype {Level,...}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue