Jump to content

Keep Interface relative to camera


xronn
 Share

Recommended Posts

Hi,

 

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

 Share

  • Recently Browsing   0 members

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