Need some help with the math please infinite scrolling Background

0 favourites
  • 7 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • C3/mobile

    The game is a little airplane. It's at the bottom of the screen. The background looks like land. The plane looks like it's fly over the land - well it's supposed to anyway.

    The game is 500x500 (just a wee little thing)

    The background is a tiledbackground 500x2384

    The variable ScrollSpeed = 400

    The background needs to be an infinite scroll. I just can't figure out the math.

    I know I need to change the Set Y, but not sure to what.

    And I'm not entirely sure I have the every tick setup correctly.

    I've watched/read a dozen tutorials today and every one says to do something similar and completely different.

    Help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • An example for infinite scroll:

    dropbox.com/s/hado7a9h3uy9nyu/moving_bacground_vari.capx

  • Missed it by "that" much:

    http://www.blackhornettechnologies.com/Construct3Stuff/Samples/InfScroll_dazedangels.zip

    The key is to have two copies, so that as one scrolls off, the other scrolls on. The other trick is to not have a fixed value, but the offset of the background's size, times two.

  • blackhornet,

    OHHH! I got it now. THANK YOU!

    If you don't mind, can I ask a related question?

    How do I get the bombs to look like they aren't hanging in the air before dropping?

    On the levels without the scrolling background the bombs drop like normal, but on this level where the background now scrolls it looks like the bombs are hanging for a second. Is that an illusion or do I need to change something with the bombs?

    The bombs are in a family and the family has physics. It's the standard physics, I haven't changed anything except checked prevent rotation (which prevent rotation isn't working, but that's another day)

    This is what it looks like

    youtu.be/5424hx2-rj8

    Thanks again.

  • alextro

    Thank you.

    So it looks like one of the tricks is always 2 backgrounds.

  • It's an illusion, because the bombs are dropping at the same speed as the background until the acceleration picks up enough to make them move faster.

  • You can do infinite scrolling using just a single tiled background object; instead of moving the X-Y position of the background there's an imageXoffset and imageYoffset value that you can adjust.

    Every tick:

    -> TiledBackground: Set image Y offset to ((Self.ImageHeight+Self.ImageOffsetY+scrollSpeed*dt)%Self.ImageHeight

    You'll find the set offset actions in the "Image" section of the actions menu

    This modulo "%" will automatically reposition the offset once it exceeds the image width.

    A negative scrollSpeed value will reverse the direction of movement (this is also why you add the image height at the start - modulo can go a bit weird with negative numbers.)

    Switch height to width and Y for X for horizontal movement.

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