love.graphics.newImage

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
feather240
Prole
Posts: 3
Joined: Mon Apr 25, 2011 12:21 am

love.graphics.newImage

Post 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
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: love.graphics.newImage

Post 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.
feather240
Prole
Posts: 3
Joined: Mon Apr 25, 2011 12:21 am

Re: love.graphics.newImage

Post 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?
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: love.graphics.newImage

Post 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 .
feather240
Prole
Posts: 3
Joined: Mon Apr 25, 2011 12:21 am

Re: love.graphics.newImage

Post by feather240 »

Okay, that makes a lot more sense. Thanks. Now to continue bug testing.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: love.graphics.newImage

Post by BlackBulletIV »

No worries :). Good luck!
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests