1 decade ago by Matthias
Hey everybody,
I just tried to implement a graphical HUD where I have symbols representing different pieces of information about the player, e.g., health, score, level, etc. I implemented the HUD as an entity that consists of several HUD elements (health, score, ..). However, the problem is that the HUD is drawn dynamically on the screen. This means the position of the HUD is adjusted according to the movement of the player, i.e., one can see visible movement of the HUD elements. When I just used the font.draw() method I didn't have that problem. Is there any way to assign a constant position of the HUD elements on the screen?
I'm spawning the HUD in game.js after all level entities have been loaded. The HUD's update and draw method call the update and draw methods of all HUD elements, respectively. In this thread (http://impactjs.com/forums/help/divs-inside-of-canvas-in-relation-to-screen-size) someone said it would matter which entity spawned the HUD. However, this doesn't make much sense to me and also didn't make any difference in my case (bouncy images).
Is it possible to directly draw on the canvas and use divs or something?
Edit: Problem seems to be solved. I'm just using the draw method of the image class.
I just tried to implement a graphical HUD where I have symbols representing different pieces of information about the player, e.g., health, score, level, etc. I implemented the HUD as an entity that consists of several HUD elements (health, score, ..). However, the problem is that the HUD is drawn dynamically on the screen. This means the position of the HUD is adjusted according to the movement of the player, i.e., one can see visible movement of the HUD elements. When I just used the font.draw() method I didn't have that problem. Is there any way to assign a constant position of the HUD elements on the screen?
I'm spawning the HUD in game.js after all level entities have been loaded. The HUD's update and draw method call the update and draw methods of all HUD elements, respectively. In this thread (http://impactjs.com/forums/help/divs-inside-of-canvas-in-relation-to-screen-size) someone said it would matter which entity spawned the HUD. However, this doesn't make much sense to me and also didn't make any difference in my case (bouncy images).
Is it possible to directly draw on the canvas and use divs or something?
Edit: Problem seems to be solved. I'm just using the draw method of the image class.