Sign in to follow this  

Group fixed to the camera only in x axis

Recommended Posts


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?


Share this post

Link to post
Share on other sites

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() { + 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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.