Difference between revisions of "Lily"

m
m (Update for v.3.0.6 (LCily page))
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
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 39: 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 65: Line 64:
 
{{#set:Keyword=Threaded Resource Loading}}
 
{{#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