Jump to content

Keep Interface relative to camera


Recommended Posts



So I recently updated my game from a fixed screen to camera following my player, I had a number of UI elements such as xp bar, coins etc.. drawn to a specific location on the screen. Now when the camera moves they stay in that location so if my player walks off down the road the ui elements are left behind how can I keep them in view in a specific position. 

Link to comment
Share on other sites

Hi xronn,

Simply set the fixedToCamera property to true on your elements. Move them to their positions relative to the camera with cameraOffset.setTo(x, y). For example:

xpBar.fixedToCamera = true;xpBar.cameraOffset.setTo(25, 700);

This fixes the xpBar to the camera and sets its x position to 25 and y position to 700 relative to the camera's x and y coordinates. :)

Link to comment
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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...