jdiperla Posted February 3, 2018 Share Posted February 3, 2018 I was hoping someone could point me in the right direction here. I see that I can set world bounds to detect when a sprite is out of bounds of that world. But I don't think that will help in what I am trying to do. I have a background image and a sprite. When the sprite reaches near the edge of the screen, the camera needs to pan the screen. My question is, is there a way to determine when the character reaches, for example, the edge of the screen to the left(minus 20 pixels or so) so that I can begin panning the camera then? Link to comment Share on other sites More sharing options...
casey Posted February 4, 2018 Share Posted February 4, 2018 Check out the Phaser scrolling component https://phaser.io/news/2017/02/phaser-scrollable-component this might also help: http://phaser.io/examples/v2/camera/smooth-follow Link to comment Share on other sites More sharing options...
ForgeableSum Posted February 4, 2018 Share Posted February 4, 2018 Simply check the .inCamera property of the sprite. Or create a Phaser.Rectangle, setting the x/y to the x/y of game.camera whenever it moves and check if the rectangle contains the position of the sprite. Link to comment Share on other sites More sharing options...
Recommended Posts