Page 1 of 1
Why does this code not work?
Posted: Wed Nov 26, 2014 10:25 am
by Sosolol261
Code: Select all
function love.draw()
function mainBackground()
love.graphics.setBackgroundColor(50, 50, 75)
love.graphics.rectangle('fill', 0, 520, 1280, 200)
end
end
Every time I run this code, I get a blackscreen.. The console doesn't tell me anything and the debugger can't find anything too.
I don't think i did anything wrong.
Re: Why does this code not work?
Posted: Wed Nov 26, 2014 12:13 pm
by Azhukar
Code: Select all
function love.draw()
love.graphics.setBackgroundColor(50, 50, 75)
love.graphics.rectangle('fill', 0, 520, 1280, 200)
end
This will work.
What your code did previously was declare function mainBackground each frame (each time love.draw was called) and then do nothing with it.
Re: Why does this code not work?
Posted: Wed Nov 26, 2014 12:55 pm
by Sosolol261
ah ok thanks

Re: Why does this code not work?
Posted: Wed Nov 26, 2014 3:40 pm
by davisdude
Alternatively, you could do
Code: Select all
function mainBackground()
love.graphics.setBackgroundColor(50, 50, 75)
love.graphics.rectangle('fill', 0, 520, 1280, 200)
end
function love.draw()
mainBackground()
end
Re: Why does this code not work?
Posted: Fri Nov 28, 2014 2:28 am
by MarkSill
Or, if you really,
really, want to:
Code: Select all
function love.draw()
function mainBackground()
love.graphics.setBackgroundColor(50, 50, 75)
love.graphics.rectangle('fill', 0, 520, 1280, 200)
end
mainBackground()
end