Hello!
I am a little new to love2d, and i wanted to start to learn how to parallax, does anyone know a good tutorial, or were I should start to learn?
Parallax Help
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Parallax Help
Parallax scrolling is relatively easy to add. For each layer of background you multiply the scrolling factor by a greater number. For example, let's suppose you have a "scroll" variable that is relative to the player position. Let's also suppose you have a table with your layers of background, from the closest to the furthest:
Code: Select all
for i = #backgrounds, 1, -1 do
local newScroll = scroll-(#backgrounds-i)*10
love.graphics.draw(backgrounds[i], newScroll, 0)
end
Re: Parallax Help
Oh, sweet, thanks a bunch!HugoBDesigner wrote:Parallax scrolling is relatively easy to add. For each layer of background you multiply the scrolling factor by a greater number. For example, let's suppose you have a "scroll" variable that is relative to the player position. Let's also suppose you have a table with your layers of background, from the closest to the furthest:Code: Select all
for i = #backgrounds, 1, -1 do local newScroll = scroll-(#backgrounds-i)*10 love.graphics.draw(backgrounds[i], newScroll, 0) end
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests