Hi all!
You know how i can create "loading" screen?
When game started or game resources loading i want show for users screen where text "Please wait, loaging"
Sorry for my english
"Loading" screen
Re: "Loading" screen
You have to load most of the stuff in your update loop. Make a game state "loading", and in it, start loading files while updating a number after every file or such. Make sure your update function returns after every few files, so that draw() can be called.
Then in your draw function, draw the word loading and a bar whose length depends on the number of files loaded.
It's not possible to draw a loading bar if you load everything in love.load, because the draw function isn't called while it's executed, and it's also not possible to load all the files in one function call, because draw() is only called whenever update() returns.
Pseudo-code to get the idea across:
Keep in mind that if you're just loading a few images this proces wil be really, really fast and you probably won't even see it happening. So don't use it unless you really have considerable amounts of loading to do.
Then in your draw function, draw the word loading and a bar whose length depends on the number of files loaded.
It's not possible to draw a loading bar if you load everything in love.load, because the draw function isn't called while it's executed, and it's also not possible to load all the files in one function call, because draw() is only called whenever update() returns.
Pseudo-code to get the idea across:
Code: Select all
love.load()
loaded = 0
files = { 'image.png', 'image2.png', 'image3.png', 'image4.png', 'etc' }
end
love.update(dt)
if #files then
file = table.remove( files )
loadFile( file )
loaded = loaded + 1
return
end
gamestate = "menu" -- or play, or whatever
end
love.draw()
love.graphics.print( 400, 20, "Loading" )
love.graphics.rectangle( "fill", 50, 50, 25*i, 50 )
end
Re: "Loading" screen
Thx. I see.
The function is ~3 sec.
Resources had times to boot.
Profit!
Good remark. I think, what i can create function with timer and show this function after each screen-transfer or loading.Plu wrote:Keep in mind that if you're just loading a few images this proces wil be really, really fast and you probably won't even see it happening. So don't use it unless you really have considerable amounts of loading to do.
The function is ~3 sec.
Resources had times to boot.
Profit!
Re: "Loading" screen
You can't show a timer counting down unless you spread the loading proces out over multiple calls to the update function. The screen is only updated between update() calls, so you need to spread the loading proces out over about 2 calls per second to get a semi-responsive loading bar.
Re: "Loading" screen
If loading only takes about 3 seconds, then you can leave out a loading bar completely and only write a text like "Loading please wait".
Have a look at the source code of Mari0, it has such a loading screen.
Have a look at the source code of Mari0, it has such a loading screen.
Check out my blog on gamedev
- SimonLarsen
- Party member
- Posts: 100
- Joined: Thu Mar 31, 2011 4:47 pm
- Location: Denmark
- Contact:
Re: "Loading" screen
This is not strictly true. This is what is done in the love.run() function:Plu wrote:It's not possible to draw a loading bar if you load everything in love.load, because the draw function isn't called while it's executed, and it's also not possible to load all the files in one function call, because draw() is only called whenever update() returns.
Code: Select all
...
if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
if love.graphics then
love.graphics.clear()
if love.draw then love.draw() end
end
if love.timer then love.timer.sleep(0.001) end
if love.graphics then love.graphics.present() end
...
Who is online
Users browsing this forum: Google [Bot], Semrush [Bot] and 3 guests