Loading Images

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
CrystalMoth
Prole
Posts: 3
Joined: Wed Mar 17, 2010 7:35 pm

Loading Images

Post by CrystalMoth »

function love.load()
pic1 = love.graphics.newImage(pic1.bmp)
end

function love.draw()
love.graphics.draw(pic1, 50, 50, 0, 0, 0, 0, 0)
end


the above is my code but it just gives me this erro:

Error
main.lua.7 attempt to index global 'pic1' a nil value
Traceback:
manin.lua.7: in function 'load'
[C:] in function 'xpcall'
User avatar
hatingcollege
Prole
Posts: 2
Joined: Tue Mar 02, 2010 4:47 am
Location: Virginia, USA
Contact:

Re: Loading Images

Post by hatingcollege »

On this line:

Code: Select all

pic1 = love.graphics.newImage(pic1.bmp)
You're forgetting to enclose your strings with quotes. Lua thinks you're trying to access the bmp index of pic1 (as if it were a table).

Fix:

Code: Select all

pic1 = love.graphics.newImage('pic1.bmp')
Post Reply

Who is online

Users browsing this forum: No registered users and 85 guests