How do I create a scrolling background?

  • When I say a scrolling background, not something that scrolls when the player moves in that direction, but a background that scrolls by itself like in a title screen or something.

  • On start of layout: set instance variable originalX to background.X

    On start of layout: set instance variable originalY to background.Y

    Every tick: Background: move at angle self.angle

    Compare two values:

    distance(background.x,background.y,

    background.originalX,background.originalY) >= tilewidth

    -->

    background: set position to self.originalX,self originalY.

    This will let you scroll at any angle you want to tilt the background, and also take care of the tile discontinuity. It is assumed you will used a tiledbackground object. 'tilewidth' is the width of the source image, so it can loop back on itself seamlessly.

  • Compare two values:

    distance(background.x,background.y,

    background.originalX,background.originalY) >= tilewidth

    -->

    background: set position to self.originalX,self originalY.

    Excuse my lack of substantial programming knowledge, but what's tilewidth?

  • I don't mean to be rude, but I still don't know what tilewidth is.

  • Aero

    'tilewidth' is the width of the source image, so it can loop back on itself seamlessly.'

    He wrote it in his post... Last sentence.

  • Also you can find capx examples in the how do I FAQ section "Scrolling/Camera"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And now I'm stupid.

    I misread that as "'tilewidth' allows you to have the source image, so it can loop back on itself seamlessly."

    I should've reread it when it didn't make sense to me. I'm sorry.

  • And it's not working.

    I'm not sure what I'm doing wrong; I followed all the steps.

    Here's my CAPX. Could someone please look at this and see what the problem is?

    http://dl.dropbox.com/u/64495006/Solar%20Power%20v0.6.capx

  • dl.dropbox.com/u/41931267/Snowfield.capx

    Sorry, it's hard to keep track of all these topics, I wish there was a way to subscribe/unsubscribe to a topic!

    Anyway, that should do it. You almost had it. I neglected to mention that the tiledbackground needs to be at least twice as wide as the screen. Really sweet title screen by the way!

  • dl.dropbox.com/u/41931267/Snowfield.capx

    Sorry, it's hard to keep track of all these topics, I wish there was a way to subscribe/unsubscribe to a topic!

    Anyway, that should do it. You almost had it. I neglected to mention that the tiledbackground needs to be at least twice as wide as the screen. Really sweet title screen by the way!

    Oh, thanks!

    Thanks for the compliment, squiddster! I'm trying to make it look as cool as possible.

    EDIT: Actually, you wouldn't happen to know if I can make it scroll but still follow along with the player?

    I don't know if you get what I'm trying to say, but if I enlarge the scrolling tiled background to, say, a bigger layout, then it will just continually tile on and on when I go up or down, and I'm trying to make it, well, not do that and not scroll to the player.

    Do you get it...? Sorry, I'm bad at explaining things. =P

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