Hello, I am having trouble with my parallax scrolling background. As you can see in the events, everything is set up the same, but for some reason the ‘Floor’ layer is giving me a gap. The other layers work just fine, and I’ve made sure its not the image. The only thing I can think of is possibly my Variable(Speed) could be effecting it? Any help would be greatly appreciated, thanks for your time.
oh yes this annoying bug it came when i tried to make an extension to auto scroll the background without connecting it to other objects like player…etc
its a weird bug i believe its there because of the elements speed and FPS that change from pc to another
anyway there is a faster way that can skip all this events and make what you want,
make a tiled sprite background object and then add this event for it
it will do the trick change the (add 1) to the speed you want,
I think you can fix this by adding 2 * Floor.Width() to the Floor position, and not set it to Floor.Width() :
You should really be applying this technique to all the other parallax scrolling objects too - it’s the correct way.
Why? Say the parallax object (call it paraObj #1) is 100 pixels wide. If it’s x position gets to -101, then the neighbouring paraObj #2 x position will be at -1, and it’s right most pixel will be to the left of 99. But you are placing the first paraObj #1 at 100, leaving a 1 pixel gap between it and paraObj #2.
But if you add 200 (2 * paraObj.Width()), then you’ll get the x position of 99, which is correct.
No, it’s not a bug. It’s an erroneous programming technique.
This is a much better technique, particularly for background images. But it may fall down if you are checking for collision with the scrolling image. Or if you want to ‘stitch’ a number of images together and scroll them.
its background parallax so i don’t think collision is needed here, and multi images together also wont be an issue as well, i don’t get your point >.<
if you are able to fix the gap issue please share it with us, nobody yet found a solution for it (the technique i mentioned is much better) but if you found a solution of that gap issue, share it with us (by making a tiny example of a background scrolling and we can control the speed of the scrolling without the gaps showing) and here is the card where you can see many attempts to fix it, but mostly failed or wasn’t smooth Trello ,we also discus it on discord long time ago when i started the topic
The image OP was having trouble with is the Floor, presumably the part the character moves and stands on.
My intention was to point out the limitations of the tiled object for anyone who searched for this and wants a continuously scrolling floor that’s potentially made up of different parts and changes from time to time (think moon patrol).
It’s that one line screen snip of the action to add double the object width to it’s current x position :
To confirm my suggestion works, I ran the online editor example you have linked in the Trello card. I changed the speed to 3.3, and saw a gap within 10 seconds. Then I changed the position update to add twice the background object width, and didn’t see a gap after letting it run for a minute.
wow its working like a charm !
you are the god of math ! <3
i will share this topic on disocrd and on trello card to let them know that you found a fix
Worked like a charm! Thank you both for your input, I will be using this technique for all of my parallax scrolling needs from now on. As always, well done MrMen!
"I think you can fix this by adding 2 * Floor.Width() to the Floor position, and not set it to Floor.Width() :
You should really be applying this technique to all the other parallax scrolling objects too - it’s the correct way."