diff --git a/docs/index.html b/docs/index.html index 01d644d..bb6ee8a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -108,7 +108,7 @@
generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
diff --git a/docs/modules/asset.html b/docs/modules/asset.html index d7c9892..4bdd1a4 100644 --- a/docs/modules/asset.html +++ b/docs/modules/asset.html @@ -334,7 +334,7 @@
generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
diff --git a/docs/modules/ecs.html b/docs/modules/ecs.html index ca2ed1e..e4484a8 100644 --- a/docs/modules/ecs.html +++ b/docs/modules/ecs.html @@ -1626,7 +1626,7 @@ its sibling systems (i.e. completely stop the propagation of the event).
generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
diff --git a/docs/modules/ldtk.html b/docs/modules/ldtk.html index 1557a66..f246f03 100644 --- a/docs/modules/ldtk.html +++ b/docs/modules/ldtk.html @@ -206,11 +206,11 @@ end The layer order: smaller order means it is on top. - Layer.offsetX + Layer.x X position of the layer relative to the level. - Layer.offsetY + Layer.y Y position of the layer relative to the level. @@ -312,7 +312,11 @@ end - + + + + + @@ -909,8 +913,8 @@ end
- - Layer.offsetX + + Layer.x
X position of the layer relative to the level. @@ -930,8 +934,8 @@ end
- - Layer.offsetY + + Layer.y
Y position of the layer relative to the level. @@ -1458,7 +1462,7 @@ end Level:draw ()
- 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 +
+
+ + Level:drawBackground () +
+
+ 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. + +

Requires:

+ + + + + + + + + +
@@ -1754,7 +1781,7 @@ end Level background.

If there is a background image, background.image contains a table {image=image, x=number, y=number, sx=number, sy=number} - where image is the LÖVE image (or image filepath if LÖVE not available) x and y are the top-left position, + where image is the LÖVE image (or image filepath if LÖVE not available) x and y are the top-left position, and sx and sy the horizontal and vertical scale factors. @@ -1829,7 +1856,7 @@ end

  • Enum are converted into a Lua string giving the currently selected enum value.
  • Filepath are converted into a Lua string giving the file path.
  • Arrays are converted into a Lua table with the elements in it as a list.
  • -
  • Points are converted into a Lua table with the fields x and y: { x=number, y=number }.
  • +
  • Points are converted into a Lua table with the fields x and y: { x=number, y=number }.
  • Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: {r,g,b}.
  • @@ -1855,7 +1882,7 @@ end
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/modules/scene.html b/docs/modules/scene.html index 0747b3c..34b6551 100644 --- a/docs/modules/scene.html +++ b/docs/modules/scene.html @@ -702,7 +702,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/modules/signal.html b/docs/modules/signal.html index 4508ac2..f5e84bb 100644 --- a/docs/modules/signal.html +++ b/docs/modules/signal.html @@ -414,7 +414,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/modules/timer.html b/docs/modules/timer.html index f79896b..6cb72a5 100644 --- a/docs/modules/timer.html +++ b/docs/modules/timer.html @@ -1153,7 +1153,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/modules/ubiquitousse.html b/docs/modules/ubiquitousse.html index ec9254b..26be33a 100644 --- a/docs/modules/ubiquitousse.html +++ b/docs/modules/ubiquitousse.html @@ -362,7 +362,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/modules/util.html b/docs/modules/util.html index 1a0545c..21b884c 100644 --- a/docs/modules/util.html +++ b/docs/modules/util.html @@ -784,7 +784,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/topics/LICENSE.html b/docs/topics/LICENSE.html index 7ba8a24..caff6fb 100644 --- a/docs/topics/LICENSE.html +++ b/docs/topics/LICENSE.html @@ -64,7 +64,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/docs/topics/README.md.html b/docs/topics/README.md.html index 995714e..608d8ae 100644 --- a/docs/topics/README.md.html +++ b/docs/topics/README.md.html @@ -71,7 +71,7 @@
    generated by LDoc 1.4.6 -Last updated 2021-12-27 13:15:05 +Last updated 2021-12-27 13:22:21
    diff --git a/ldtk/ldtk.can b/ldtk/ldtk.can index cf019b3..b0ed06e 100644 --- a/ldtk/ldtk.can +++ b/ldtk/ldtk.can @@ -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,21 +450,29 @@ let level_mt = { assert(@loaded == true, "level not loaded") lg.push() lg.translate(@x, @y) - -- background color - lg.setColor(@background.color) - lg.rectangle("fill", 0, 0, @width, @height) - -- background image - lg.setColor(white) - let bgImage = @background.image - if bgImage then - lg.draw(bgImage.image, bgImage.quad, bgImage.x, bgImage.y, 0, bgImage.sx, bgImage.sy) - end + @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) + -- background image + lg.setColor(white) + let bgImage = @background.image + if bgImage then + lg.draw(bgImage.image, bgImage.quad, bgImage.x, bgImage.y, 0, bgImage.sx, bgImage.sy) + end + end, --- Load the level. -- Will load every layer in the level and the associated images. @@ -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,...}
    Level:draw ()Draw this level.Draw this level (background and layers).
    Level:drawBackground ()Draw this level background.
    Level:load ([, callbacks])