I have a game where the camera zooms out when the players gets big. When the player gets bigger, the tilesprite moves a little to the left, is there any way to fix this?
Zoom out code:
if(!(this.cameras.main.zoom <= 0.15)) {
if(player.scale < 0.75) this.cameras.main.zoomTo(1.25-player.scale);
if(player.scale >= 3) this.cameras.main.zoomTo(0.56-((player.scale-1)/8));
else if(player.scale >= 1) this.cameras.main.zoomTo(0.56-((player.scale-1)/8));
else if(player.scale >= 0.75) this.cameras.main.zoomTo(0.56-((player.scale-0.75)/3));
}
this.background.setTileScale(this.cameras.main.zoom, this.cameras.main.zoom);
this.background.displayWidth = this.cameras.main.displayWidth;
this.background.displayHeight = this.cameras.main.displayHeight;
this.background.setTilePosition(this.cameras.main.scrollX, this.cameras.main.scrollY);
Video of glitch: Notice how once i break the chest, the tilemap moves a bit to left.