How can I implement parallax scrolling with Paper2D?

Let’s forget about blueprints and Paper2D for a moment and try to understand the concept of parallax scrolling. If we can’t understand the concept, we have no hope of implementing it.

So, you have a character which can move left or right on the screen. Lets say that the character stays centered on the screen at all times. We want to show character movement by moving all other objects, relative to the character. So, if you walk to the left by 5 pixels, ALL other game objects should be shifted to the RIGHT by 5 pixels, right? So if you have a simple background, we move the background to the right by 5 pixels. This background has a 1:1 ratio to character movement. Let’s call this background “Layer 0”.

With parallax, we want to add a second background layer behind “Layer 0”. This background layer is more distant, so it should move slower relative to the character movement. Perhaps we assign a ratio of 1:2. If the player moves to the left 5 pixels, this background layer moves 2.5 pixels to the right. Let’s call this “Layer 1”. We can simplify the amount the background moves as a fraction of player movement: 1/2

Maybe we add a third background layer, such as distant mountains. This is “layer 2”, and we can give it a fractional movement amount of 1/3 or 1/4, whatever looks best.

Now, to implementation… your parallax backgrounds are really just large sprite textures with tiling. If you know how to load and move a sprite, you can implement parallax backgrounds :slight_smile: I would tie the background movement to character movement events. Generally, you move the background relative to the character, but if the character reaches the edge of the map, you move the character instead of the map. I leave that part for you to figure out, it’s pretty easy :wink: