[SOLVED] About drawing images on screen

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

[SOLVED] About drawing images on screen

Post 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?
Last edited by nice on Fri Oct 03, 2014 7:19 pm, edited 1 time in total.
:awesome: Have a good day! :ultraglee:
User avatar
zorg
Party member
Posts: 3091
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: [QUESTION] About drawing images on screen

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: [QUESTION] About drawing images on screen

Post 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?
:awesome: Have a good day! :ultraglee:
User avatar
zorg
Party member
Posts: 3091
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: [QUESTION] About drawing images on screen

Post 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]
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: [SOLVED] About drawing images on screen

Post by nice »

Thanks for the help, I think I have a better understanding now.
:awesome: Have a good day! :ultraglee:
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests