Loading screens...

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Loading screens...

Post by Chief »

Since LUA runs in one "lane" I've been stumbling over some problems with drawing a loading screen at the same time that the game is loading new resources. Anyone have any ideas to get around this? Maybe threading? :huh:
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Loading screens...

Post by Tesselode »

How about putting something in the update callback like this:

Code: Select all

if screen then
screen="load"
--load resources
else
screen="loading_screen"
end
And then in the draw callback have something like:

Code: Select all

if screen="loading_screen" then
--draw loading message
end
That way the game should get a chance to draw a loading message before it starts loading.
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: Loading screens...

Post by Chief »

Hmmyes, i catch your drift. Might just wanna stop the loading a little bit to make a breathing space for the draw function to run. Imma' try that!
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Loading screens...

Post by vrld »

Use coroutines, which are basically lightweight threads.

loader pseudocode:

Code: Select all

loader = coroutine.create(function()
    for type, source in pairs(resources_to_load) do
        load_resource(type, source)
        coroutine.yield()
    end
end)
love.update:

Code: Select all

coroutine.resume(loader)
if coroutine.status(loader) == "dead" then
    -- loading finished
end
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: Loading screens...

Post by Chief »

I went for the coroutines, and it worked perfectly!

Until i noticed something strange! The bodies and shapes (physics) doesn't seem to be working properly (gives error) when colliding with props made outside of the coroutine.

The error is basically that it returns "attempt to call a number value" in the physics world update...

Gotta look into this more, if no one else got a theory on how to fix this of course :awesome:
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Loading screens...

Post by bmelts »

Full-fledged love.thread is coming in 0.7.0.
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: Loading screens...

Post by Luiji »

Funnu thing, I was just going to ask about this.
anjo wrote:Full-fledged love.thread is coming in 0.7.0.
I can't wait!
Good bye.
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: Loading screens...

Post by Chief »

anjo wrote:Full-fledged love.thread is coming in 0.7.0.
And when is that if I may ask? :P
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Loading screens...

Post by nevon »

Chief wrote:
anjo wrote:Full-fledged love.thread is coming in 0.7.0.
And when is that if I may ask? :P
Around the same time as the audio issues are solved.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Loading screens...

Post by bartbes »

With the difference that love.thread already exists.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests