Page 1 of 2

a question about love.graphics.newImage( filename )

Posted: Sat Jul 24, 2010 1:52 pm
by poorenglish
er,hello;
in the wiki
-----------------------------------------------------------------
image = love.graphics.newImage( filename )
string filename
The filepath to the image file.
-----------------------------------------------------------------
in this function,the absolute file path of walkr.png is "D:\Program Files\LOVE062\Test4\walkr.png",the program is in the D:\Program Files\LOVE062\Test4.
function love.draw()
image2 = love.graphics.newImage("walkr.png")--it is OK
image3 = love.graphics.newImage("D:\\Program Files\\LOVE062\\Test4\\walkr.png")--error in the love,can't open this file,does not exist.
love.graphics.draw(image2,100,100)
end


why?The image file name does not support the absolute file path?
How,I can load the image file from other directory,I do not hope the program being too bigger.
THKs every one

Re: a question about love.graphics.newImage( filename )

Posted: Sat Jul 24, 2010 2:00 pm
by bartbes
Because love has its own filesystem, which consist of the .love (or game folder) and the save dir, so everything is relative to that (and paths are written unix-style btw).

Re: a question about love.graphics.newImage( filename )

Posted: Sat Jul 24, 2010 2:19 pm
by poorenglish
bartbes wrote:Because love has its own filesystem, which consist of the .love (or game folder) and the save dir, so everything is relative to that (and paths are written unix-style btw).
So,I can't load image file from directory which is not relative the .love in the windows XP?
It will make the .love too bigger!!
How I can make the .love file be smaller?

Re: a question about love.graphics.newImage( filename )

Posted: Sat Jul 24, 2010 2:26 pm
by bartbes
What were your plans anyway? If you distribute it, you're going to have to distribute everything with it anyway.

Re: a question about love.graphics.newImage( filename )

Posted: Sat Jul 24, 2010 3:25 pm
by Robin
Also, don't create new images in love.draw() -- this will load it every single frame. Use love.load() for that instead.

Re: a question about love.graphics.newImage( filename )

Posted: Sun Jul 25, 2010 9:21 am
by Chief
poorenglish wrote:
FIXED:

function love.load()
image2 = love.graphics.newImage("walkr.png")--run once to set image
end

function love.draw()
love.graphics.draw(image2,100,100) -- has to be run every frame
end
You can place your image in "C:\Users\NameOfUser\AppData\Roaming\LOVE\YourGame" or i your project folder. Up to you really.

Re: a question about love.graphics.newImage( filename )

Posted: Sun Jul 25, 2010 9:24 am
by Robin
Chief wrote:You can place your image in "C:\Users\NameOfUser\AppData\Roaming\LOVE\YourGame" or i your project folder. Up to you really.
But you still have to distribute it, as bartbes pointed out. Putting things like that in the .love make things easier both for the lover and the gamer.

Re: a question about love.graphics.newImage( filename )

Posted: Sun Jul 25, 2010 1:41 pm
by poorenglish
Robin wrote:
Chief wrote:You can place your image in "C:\Users\NameOfUser\AppData\Roaming\LOVE\YourGame" or i your project folder. Up to you really.
But you still have to distribute it, as bartbes pointed out. Putting things like that in the .love make things easier both for the lover and the gamer.
I know it will be easier.
But I only hope I can control the location of the resource files.
I hope the resource files such as images,sounds will be outside the game executable file.
And an another question?
the function about love.filesystem.setSource( )
When I run this function in the love.load(),the function needs argument,but there is not any instruction in the Wiki http://love2d.org/wiki/love.filesystem.setSource
Anything help?

Re: a question about love.graphics.newImage( filename )

Posted: Sun Jul 25, 2010 1:45 pm
by bartbes
Docs wrote:can only be called once, done automatically.
Hmm..

Re: a question about love.graphics.newImage( filename )

Posted: Sun Jul 25, 2010 5:03 pm
by Robin
bartbes wrote:Hmm..
To clarify: setSource() sets the location of the .love (as in, where it can find it), so if you want to set it in your main.lua, it means it has to find itself before it can find itself, causing a paradox. So you can't use setSource() yourself. ;)