Page 1 of 1
Scrolling horizontal background
Posted: Sun Aug 21, 2016 6:47 pm
by benbooth493
Hello all!
I'm new to Love2D and I'm already making great progress, but I am stuck trying to implement a horizontal scrolling background.
What is the best way to do this?
Thanks in advance!
Ben
Re: Scrolling horizontal background
Posted: Mon Aug 22, 2016 7:21 pm
by CanadianGamer
Welcome to the forums.
All you need to do is change the x coordinate of where the background is being drawn.
For example if you are currently drawing the background at 0, 0 try drawing it at progressively
smaller or larger x coordinates to make it 'move'.
Re: Scrolling horizontal background
Posted: Tue Aug 23, 2016 6:13 pm
by Skeletonxf
You've got two options. Either you have a fixed camera and move everything each frame to move around the viewpoint or you have fixed things on the screen and move the screen/camera around to move the view.
While the former method may be a little easier than if you opt for moving the screen instead then when you change the x and y coords of something you really know it moved from its prior position relative to the viewpoint.
There's libraries for the moving camera such as hump.camera or you can use the Love2d features with love.graphics.translate and do it yourself.