a question about love.graphics.newImage( filename )

General discussion about LÖVE, Lua, game development, puns, and unicorns.
poorenglish
Prole
Posts: 47
Joined: Thu Sep 24, 2009 1:49 pm

a question about love.graphics.newImage( filename )

Post 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
User avatar
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 )

Post 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).
poorenglish
Prole
Posts: 47
Joined: Thu Sep 24, 2009 1:49 pm

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

Post 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?
User avatar
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 )

Post by bartbes »

What were your plans anyway? If you distribute it, you're going to have to distribute everything with it anyway.
User avatar
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 )

Post by Robin »

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.
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

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

Post 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.
User avatar
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 )

Post 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.
Help us help you: attach a .love.
poorenglish
Prole
Posts: 47
Joined: Thu Sep 24, 2009 1:49 pm

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

Post 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?
User avatar
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 )

Post by bartbes »

Docs wrote:can only be called once, done automatically.
Hmm..
User avatar
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 )

Post 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. ;)
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests