How do I improve my tiled backgrounds? [SOLVED]

0 favourites
  • 3 posts
From the Asset Store
City ride is a game to improve your memory.You have to focus and remember the information related to passengers of previ
  • 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.

    For example,

    -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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • in construct 3 there is a new addition in TiledBackground which you can use to make infinite scrolling

    Iamge offset X and Image Offset Y. So if you want your bg to scroll left-right infinite then you should use

    every tick set tiled background.imageOffsetX to Self.ImageOffsetX-10

    or if you are using bullet behavior in any object then you can set it to Self.ImageOffsetX-bulletSpeed*dt

  • I tried a few things that worked nicely. Thank You!

    Ultimately since my game doesn't scroll constantly I had to go back to my method. I fixed it by doing some math. I had to take into account that I only shift the tiled bg X after the move is over. So I had to expand the tileBg size to double the screen plus the character's move distance and make sure it is was an even multiple of the sprite size (to keep from jerky effect) . Sounds crazy but it works now some I'm going with it ;)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)