Page 1 of 1

love.graphics.newImage

Posted: Mon Apr 25, 2011 12:44 am
by feather240
Can I get a little help? No matter what I do with my code I'm told my image file doesn't exist.

main.lua

Code: Select all

function love.load()
	require("tile")
	
	map = 
	{
	width = 120,
	height = 240,
	x = 0,
	y = 0,
	layout = map_generate(layout)
	}
	
	tilesetBatch = love.graphics.newSpriteBatch(tileset.set, (tileset.Width / tileset.QuadWidth), (tileset.Height / tileset.QuadHeight))
end
function love.draw()
	require("blit")
end
tile.lua

Code: Select all

tileset = 
	{
	set = love.graphics.newImage("tileset.png"), --Tileset to be used
	QuadWidth = 8, --The width of a blit piece
	QuadHeight = 16, --The height of a blit piece
	Width = 128, --The width of the tileset
	Height = 256, --The height of the tileset
	}
This is the line that is causing the problems.

Code: Select all

set = love.graphics.newImage("tileset.png"), --Tileset to be used
Here's the error message.

Code: Select all

Error

Could not open file tileset.png. Does not exist.

Traceback

[C]: ?
[C]: in function 'newImage'
.\tile.lua:3 in main chunk
[C]: in function 'require'
main.lua:2: in function 'load'
[C]: in function 'xpcall'
Here's a picture of my folder so you can see the files.
Image

Uploaded with ImageShack.us

Re: love.graphics.newImage

Posted: Mon Apr 25, 2011 12:49 am
by BlackBulletIV
Are you running main.love or or the entire folder? You'll need to include the image in your .love file, if you're not already.

Re: love.graphics.newImage

Posted: Mon Apr 25, 2011 12:52 am
by feather240
BlackBulletIV wrote:Are you running main.love or or the entire folder? You'll need to include the image in your .love file, if you're not already.
I'm running "main.love". How would I include the image or run the entire folder?

Re: love.graphics.newImage

Posted: Mon Apr 25, 2011 1:06 am
by BlackBulletIV
No wonder you're having trouble. To make a .love file, you need to select all the files and folders in the directory that main.lua resides in, and zip them up. See Game Distribution. A better way to run it while in development, is to run the folder as I mentioned. To do this, you can either drag the folder to love.exe, or, if you've set up the command line in Windows, you can execute:

Code: Select all

love path\to\your\epic\game
Which means if your current directory is the folder of the game, you can execute:

Code: Select all

love .

Re: love.graphics.newImage

Posted: Mon Apr 25, 2011 1:20 am
by feather240
Okay, that makes a lot more sense. Thanks. Now to continue bug testing.

Re: love.graphics.newImage

Posted: Mon Apr 25, 2011 4:31 am
by BlackBulletIV
No worries :). Good luck!