Difference between revisions of "Lily"

m (Fix Lily appears at very top in Category:Libraries)
m
Line 56: Line 56:
  
 
== 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}}

Revision as of 14:58, 8 January 2018

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 correstpond to Lily v2.0

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
	})
	local a = love.timer.getTime()
	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