I had used the same code for the ‘land’ as the infinite scrolling background (which I replaced with mine and it worked), but the ‘land’ just can’t seem to scroll infinitely. Are there any other solutions to make the ‘land’ for endless runner? Or did I do something wrong?
Edit: It did worked, but there are holes, constantly
What exactly does the code do? Are the holes big or more like 1 pixel lines between objects? If it is the former you create it at the wrong position. If it is the later there could be multible reasons for it but one easy fix would be adding +0.1 width to the ground (and drawing it 0.05 further to the left).
Are you using the exact same code for the land as for the background? Do they have the exact same width? I don’t know the events so I am just guessing here.
I am not sure how exactly your code works but what I would do is simply create the level in chunks. Ideally around the size of the typical screen you target.
Check the (camera position + width) - speed and if it is about to enter a new chunk you create it. Don’t forget to delete passed chunks. That way you’ll always have 2 active chunks and the performance should be good.
:“if the x position of the background is <= then the width of the image, set x position of the backround to be the width of the image just next to the one currently on the screen and basically make the two constantly swap each other”
X of object <= object_width, do = object_width to x of object
The holes are quite big
And no they do not have the same width
The ground needs to be at least as wide as the screen for this to work.
Why are you comparing X position to width? Is your game moving right?
Edit: if your game is moving very fast this here will create holes too: object_width to x of object. Consider the x postion of the other object too.