Lily - LÖVE Async Loading Library

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
AuahDark
Prole
Posts: 46
Joined: Mon Oct 23, 2017 2:34 pm
Location: Indonesia
Contact:

Lily - LÖVE Async Loading Library

Post by AuahDark » Fri Jan 05, 2018 12:00 pm

TL;DR: love-loader but uses events and multiple CPUs

Single loading example

Code: Select all

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 example

Code: Select all

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
GitHub Repository
Profile. I don't always online in forum, so Discord is preferred. Am I LÖVE for Android dev or not? Only you can tell.

KayleMaster
Party member
Posts: 223
Joined: Mon Aug 29, 2016 8:51 am

Re: Lily - LÖVE Async Loading Library

Post by KayleMaster » Fri Jan 05, 2018 3:44 pm

I've been using this library before it was posted here, can assure you - it's great.
Your game won't freeze up on start if you're loading a lot of files (or big ones) and thus won't come up as not responding.
I'm using this with gamestate from hump and I've got myself a nice loading screen that isn't a still picture.

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests