blackbox Posted February 15, 2016 Share Posted February 15, 2016 Hi, for my specific goal I need to have a group of components which are fixed to the camera, but only in x axis. What I mean is that if a player moves left or right, the group moves with the player (is fixed to the camera), but when the player moves up or down, the components behave like if they were part of the world (not fixed to the camera). What's the best (or any) way to implement this within Phaser? Thanks! Link to comment Share on other sites More sharing options...
fillmoreb Posted February 16, 2016 Share Posted February 16, 2016 To do this, I would ignore the fixed to camera functionality, and instead use Phaser.Camera.focusOnXY() inside your update loop to move the camera with your group. Something like this: function update() { game.camera.focusOnXY(myGroup.x + myGroup.width/2, 100); } That snippet should focus on the center of the group in the x direction, but keep the y coordinate always at 100. This is basically how Phaser.Camera.follow() works under the hood anyways. blackbox 1 Link to comment Share on other sites More sharing options...
Recommended Posts