Difference between revisions of "Lily"

(Lily LÖVE Async Loading Library)
 
m (Update for v.3.0.6 (LCily page))
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
Lily, LÖVE Async Loading Library.
 
Lily, LÖVE Async Loading Library.
 +
 
Allows you to load resources in separate thread, like [[love-loader]] but uses more threads (which means faster) and more functions. It supports many resources, like [[Image]], [[ImageData]], [[Video]], [[Source]], [[SoundData]], and more.
 
Allows you to load resources in separate thread, like [[love-loader]] but uses more threads (which means faster) and more functions. It supports many resources, like [[Image]], [[ImageData]], [[Video]], [[Source]], [[SoundData]], and more.
  
Example below correstpond to Lily v2.0
+
Example below correspond to Lily v3.0.6
  
 
== Examples ==
 
== Examples ==
Line 38: Line 39:
 
{lily.newImage, love.filesystem.newFile("image1-1.png")}, -- or the function object
 
{lily.newImage, love.filesystem.newFile("image1-1.png")}, -- or the function object
 
})
 
})
local a = love.timer.getTime()
 
 
multilily:onComplete(function(_, lilies)
 
multilily:onComplete(function(_, lilies)
 
image1 = lilies[1][1]
 
image1 = lilies[1][1]
Line 55: Line 55:
  
 
== Links ==
 
== Links ==
[https://github.com/MikuAuahDark/lily GitHub Repository] (including documentation)
+
* [https://github.com/MikuAuahDark/lily GitHub Repository] (including documentation)
 +
* [https://love2d.org/forums/viewtopic.php?f=5&t=84750 Forum Post]
  
{{#set:LOVE Version=[[0.10.0]]}}
+
{{#set:LOVE Version=0.10.0}}
{{#set:LOVE Min Version=[[0.10.0]]}}
+
{{#set:LOVE Min Version=0.10.0}}
 
{{#set:Description=LÖVE Async Loading Library}}
 
{{#set:Description=LÖVE Async Loading Library}}
 
{{#set:Standalone_Lua_Module=Yes}}
 
{{#set:Standalone_Lua_Module=Yes}}
 +
{{#set:Keyword=Threaded Resource Loading}}
 
[[Category:Libraries]]
 
[[Category:Libraries]]
 +
== Other Languages ==
 +
{{i18n|Lily}}

Latest revision as of 12:30, 17 December 2019

Lily, LÖVE Async Loading Library.

Allows you to load resources in separate thread, like love-loader but uses more threads (which means faster) and more functions. It supports many resources, like Image, ImageData, Video, Source, SoundData, and more.

Example below correspond to Lily v3.0.6

Examples

Single loading

local lily = require("lily")
local myimage
local mysound

function love.load()
	lily.newImage("image.png"):onComplete(function(userdata, image)
		-- In v2.0, there's "userdata" before the return value
		myimage = image
	end)
	lily.newSource("song.wav"):onComplete(function(userdata, sound)
		-- In v2.0, there's "userdata" before the return value
		mysound = sound
		sound:play()
	end)
end

function love.draw()
	if myimage then love.graphics.draw(myimage, 0, 24, 0, 0.25, 0.25)
	else love.graphics.print("Loading image") end
	if not(mysound) then love.graphics.print("Loading song", 0, 12) end
end

Multi loading

local lily = require("lily")

function love.load()
	multilily = lily.loadMulti({
		{"newImage", "image1-0.png"},	-- You can use string
		{lily.newImage, love.filesystem.newFile("image1-1.png")},	-- or the function object
	})
	multilily:onComplete(function(_, lilies)
		image1 = lilies[1][1]
		image2 = lilies[2][1]
	end)
end

function love.update() end
function love.draw()
	if multilily:isComplete() then
		love.graphics.draw(image1, -1024, -1024)
		love.graphics.draw(image2)
	end
end

Links

Other Languages