I'm making a game in which the camera follows the player as they move across the level. But I'm having trouble with the background.
The game window is 1600 x 900, while the background image is 3400 x 900, all in pixels. The player starts at on the left of the level and the camera follows them as they move to the right.
This is the code in which I create the background:
this.bg = this.add.tileSprite(0,0, game.config.width, game.config.height, 'meadowZone').setOrigin(0,0);
And this is the code that controls the camera:
his.cameras.main.setBounds(0, 0, 3400, 900);
this.cameras.main.startFollow(this.p1, true, 0.05, 0.05);
While the code is working in letting the camera follow the player, when the camera scrolls beyond what is shown when the game first loads, I just get black. How can I fix this?
If it helps, I'm using Phaser 3 in VSCode, employing arcade physics.