Background follow camera

Hello, i have image with size of canvas add like a background to my game.

Map in game is bigger than canvas (canvas: 500px, map: 2000px);

Camera follow player, but background image stay on set position.

My solution is

**// this.bg is my background addint like a sprite**

**this.bg.x = this.cameras.cameras[0].scrollX;**

Background position in above code is setting like camera scroll X, but this not work correctly, black bars appear on the edges of the screen during movement.

What is solution for this?

I guess you are looking for setScrollFactor(number)

Try this

this.bg.setScrollFactor(0)
1 Like

Work awesome! Thanks so much :slight_smile:

1 Like