I know how to add a background image, it's possibly the simplest thing ever. The thing is, with a conditional statement (if() in this case), when I try to set a background image to a condition, it just displays a completely black screen. I've tried setting the background color to (255,255,255), and it's still a completely black background.. I'm not sure what's wrong. Here's the code for my function love.draw.
Code: Select all
function love.draw()
if (state=='playing') then
love.graphics.draw(hills, 0, 0)
love.graphics.draw(player.image, player.x, player.y)
end
if (state=='menu') then
button_draw()
love.graphics.draw(menuBackground, 0, 0)
end
end
Code: Select all
menuBackground=love.graphics.newImage('/sprites/menu.png')
Code: Select all
button={}
function button_spawn(x,y,text,id)
table.insert(button, {x=x, y=y, text=text, id=id})
end
function button_draw()
for i,v in ipairs(button) do
love.graphics.setColor(0,0,0)
love.graphics.setFont(fixedsys)
love.graphics.print(v.text,v.x,v.y)
end
end
function button_click(x,y)
for i,v in ipairs(button) do
if (x > v.x and
x < v.x + fixedsys:getWidth(v.text) and
y > v.y and
y < v.y + fixedsys:getHeight()) then
if (v.id=='quit') then
love.event.push('quit')
end
end
end
end