Skip to content

Doing a HUD in a Tiled project with a camera #2741

Closed Answered by eonarheim
depsypher asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @depsypher great question! There are a couple strategies here:

  1. If you're trying to define hud elements in Tiled you could decorated them with a specific name and then access them to change their TransformComponent to screen coordinates. (You'll need to manage scale manually since switching to the screen coordinates takes the camera transform out of account). This might be wonky to work with since the position in Tiled will no longer match up to the screen in the game.
const HUDEntities = game.currentScene.world.entityManager.getByName("HUD");
      for (let entity of HUDEntities) {
         const tx = entity.get(ex.TransformComponent);
         if (tx) {
            tx.coordPlane = ex.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by depsypher
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants