I have a tiled background that is similar to that of an endless runner but doesn't move all the time. I only move it on a certain condition.
First issue: Since the background does not move all of the time AND I need it to get to the new X in a set amount of time, I am currently using tween to change the tiled background X to self.x - movedistance when a condition is met. This seems to work fine, just wanted to check if I should do this a better way.
Main issue: I am looking for a known formula to shift the X value of my tiled background to make it seamless and endless. I'm currently using tileBG.X + tileBG.Width/2. This works for some of the tiled backgrounds but one of them will have a gap before it shifts and fills back in.
-the screen width is 1080
-I have an 80 pixel sprite tiled to 2160 width, this one works
-Another 128 pixel sprite tiled to 2176
-The background movedistance is -400 (NOTE: I all worked fine when the movedistance was -80)
-I currently wait until the tween is done to check if a shift is needed, this causes the gap
-If I do it immediately there is no gap but my tween is still playing and sometimes its noticeable when it shifts X.
So, my main goal is to move the tiledbackground endless and seamless (no gaps) only when a condition is met and it must arrive at new x in set amount of seconds.
Thanks for any suggestions!