Page 1 of 1
[SOLVED] About drawing images on screen
Posted: Fri Oct 03, 2014 12:13 pm
by nice
Hello boys and girls!
I have a Ui that I'm gonna draw on the screen and my question is that my image (it's called heliumUI.png) is inside my project folder (called helium) and I did something similar a little bit more than half a year ago where I drew a image that I had made on to the screen but I had those images on my desktop.
I'm wondering if I have to move my ui (heliumUI.png) to the desktop or can I draw it from my project folder (helium) or does Löve know that I have it in my project folder?
Might sound like a stupid question but the project is part of refreshing my memory of lua/löve so I'm sorry for any inconveniences.
[EDIT]
Right now I have put the image under love.load and it looks like this:
Code: Select all
ui = love.graphics.newImage("heliumUI.png")
I know that graphics is supposed to be drawn inside love.graphics but I have a hunch that I'll need my "ui" under love.load instead or am I wrong?
Re: [QUESTION] About drawing images on screen
Posted: Fri Oct 03, 2014 4:57 pm
by zorg
You are correct, that you are to draw things inside love.graphics, and for actually creating the stuff you want to draw (like making a new image with love.graphics.newImage) can be done as you did, in love.load, or somewhere where it's not called every frame. (calling this in love.draw would needlessly create dozens of new images each second)
As for where those images (or any other assets) are stored, love can only reliably look in two places for files, the project's folder (or inside a love), and the user's save folder associated with the game.
Note that this is only true for love.filesystem functions; if you want to use lua's io library, then you can access files from elsewhere, but if i recall correctly, the problem with that was cross-platform issues, i believe.
Re: [QUESTION] About drawing images on screen
Posted: Fri Oct 03, 2014 5:31 pm
by nice
zorg wrote:You are correct, that you are to draw things inside love.graphics, and for actually creating the stuff you want to draw (like making a new image with love.graphics.newImage) can be done as you did, in love.load, or somewhere where it's not called every frame. (calling this in love.draw would needlessly create dozens of new images each second)
As for where those images (or any other assets) are stored, love can only reliably look in two places for files, the project's folder (or inside a love), and the user's save folder associated with the game.
I currently keeping my project folder inside the documents folder (mac), is it still possible to access my heliumUI.png image from there?
zorg wrote:Note that this is only true for love.filesystem functions; if you want to use lua's io library, then you can access files from elsewhere, but if i recall correctly, the problem with that was cross-platform issues, i believe.
Could you elaborate further about this?
Re: [QUESTION] About drawing images on screen
Posted: Fri Oct 03, 2014 7:04 pm
by zorg
It does not matter where your project folder is, as long as the assets are inside that folder; love.filesystem handles files relatively, with the "top" folder being... both the project's and the save directory.
As for me recommending the use of love.filesystem functions instead of io functions, a bigger reason for it is that you might not have permissions to access/read/write other folders; love guarantees that you can read from your project folder (and from the .love file itself), and that you can read from and write to the save folder of your game.
And a game's more honest if it just doesn't have the ability to access and modify just ANY file on your computer, only in select places.
(That said, my beliefs on this matter are somewhat different, but that's irrelevant here.)
in any case, the wiki is tremendously helpful still: [wiki]love.filesystem[/wiki]
Re: [SOLVED] About drawing images on screen
Posted: Fri Oct 03, 2014 7:19 pm
by nice
Thanks for the help, I think I have a better understanding now.