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
a question about love.graphics.newImage( filename )
-
- Prole
- Posts: 47
- Joined: Thu Sep 24, 2009 1:49 pm
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: a question about love.graphics.newImage( filename )
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).
-
- Prole
- Posts: 47
- Joined: Thu Sep 24, 2009 1:49 pm
Re: a question about love.graphics.newImage( filename )
So,I can't load image file from directory which is not relative the .love in the windows XP?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).
It will make the .love too bigger!!
How I can make the .love file be smaller?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: a question about love.graphics.newImage( filename )
What were your plans anyway? If you distribute it, you're going to have to distribute everything with it anyway.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: a question about love.graphics.newImage( filename )
Also, don't create new images in love.draw() -- this will load it every single frame. Use love.load() for that instead.
Help us help you: attach a .love.
Re: a question about love.graphics.newImage( filename )
You can place your image in "C:\Users\NameOfUser\AppData\Roaming\LOVE\YourGame" or i your project folder. Up to you really.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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: a question about love.graphics.newImage( filename )
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.Chief wrote:You can place your image in "C:\Users\NameOfUser\AppData\Roaming\LOVE\YourGame" or i your project folder. Up to you really.
Help us help you: attach a .love.
-
- Prole
- Posts: 47
- Joined: Thu Sep 24, 2009 1:49 pm
Re: a question about love.graphics.newImage( filename )
I know it will be easier.Robin wrote: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.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 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?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: a question about love.graphics.newImage( filename )
Hmm..Docs wrote:can only be called once, done automatically.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: a question about love.graphics.newImage( filename )
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.bartbes wrote:Hmm..
Help us help you: attach a .love.
Who is online
Users browsing this forum: Google [Bot] and 3 guests