Background image?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 3
- Joined: Sat Sep 15, 2012 4:39 pm
Background image?
Is there a way to add a background image? Sorry for such a simple question, but I can't find how to anywhere, and can you make it repeat? Thanks in advance.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Background image?
If you do it manually like this, yes:
EDIT: this version tiles the background
Note if the background is really small, you might want to use another approach, like SpriteBatch or Canvas.
Code: Select all
function love.load()
-- other things
background = love.graphics.newImage("yourbackgroundfile.png")
end
-- other callbacks
function love.draw()
for i = 0, love.graphics.getWidth() / background:getWidth() do
for j = 0, love.graphics.getHeight() / background:getHeight() do
love.graphics.draw(background, i * background:getWidth(), j * background:getHeight())
end
end
-- draw other things
end
Note if the background is really small, you might want to use another approach, like SpriteBatch or Canvas.
Last edited by Robin on Sat Sep 15, 2012 6:24 pm, edited 1 time in total.
Help us help you: attach a .love.
-
- Prole
- Posts: 3
- Joined: Sat Sep 15, 2012 4:39 pm
Re: Background image?
Thanks, another thing, how would I make it repeat?
-
- Prole
- Posts: 3
- Joined: Sat Sep 15, 2012 4:39 pm
Re: Background image?
Thanks
I shall learn what I can from this :U
I shall learn what I can from this :U
Who is online
Users browsing this forum: Google [Bot], Semrush [Bot] and 5 guests