Whenever I add this.cameras.main.startFollow(this.player)
to my Game.js
file the game no longer renders and all I see is a black screen. If I remove it the the game renders fine.
What I am going for is to have the scroll follow the player only when they are not at the edge of the map. I have also tried using setBounds()
with it.
this.cameras.main.setBounds(0, 0, map.width, map.height); //also tried 1600, 1760 for w&h
this.cameras.main.startFollow(this.player)
Like I said if I take those lines out the game comes back and I can move the player but obviously the camera doesn’t move.
Here is the part from the create()
method in the Game.js
file.
//...more stuff before here
this.player = new Player(this, 100, 100);
this.cameras.main.setBounds(0, 0, map.width, map.height);
this.cameras.main.startFollow(this.player)
}
Any help would be great.