Can't load image

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.
Post Reply
User avatar
hey5000
Prole
Posts: 4
Joined: Tue Jan 13, 2009 7:21 am
Location: Georgia

Can't load image

Post by hey5000 »

Call me stupid, but after using this code I get an error. I can't think of what is wrong with it, maybe I'm missing something obvious here. I dunno.
I have tried

1. No '/' at the end
2. Using just '\'
3. Putting two '/' at the end

Tried searching on the forums here a while back, too.
Code:

Code: Select all

function load()
image = love.graphics.newImage ("C:/Images [LOVE]/no1tb_icons_yotsuba8.png/")
end

function draw() 
love.graphics.draw (image, 400, 400)
end
Error:

Image
User avatar
Tenoch
Citizen
Posts: 76
Joined: Mon Jul 21, 2008 7:49 am

Re: Can't load image

Post by Tenoch »

You can't load stuff from anywhere you want actually. It has to be in the same folder as your main.lua (or a subfolder), and to use the filename only:

Code: Select all

love.graphics.newImage("blah.png")
love.graphics.newImage("subfolder/blah.png")
This way, when you zip up your game folder into a .love file, it still works. Well it's the only way anyway.

In fact it's not exactly correct, when the image is not found, LÖVE also looks in the so called "save directory", which is explained in the doc, section love.filesystem. But most of the time you want to include your images in your .love anyway.
"When in doubt, use brute force." Ken Thompson
User avatar
hey5000
Prole
Posts: 4
Joined: Tue Jan 13, 2009 7:21 am
Location: Georgia

Re: Can't load image

Post by hey5000 »

Thanks, it now works. But man, I feel stupid. :ultraglee:
User avatar
Tenoch
Citizen
Posts: 76
Joined: Mon Jul 21, 2008 7:49 am

Re: Can't load image

Post by Tenoch »

Heh don't worry about it :)
"When in doubt, use brute force." Ken Thompson
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests