I'm trying to create a HUD in the upper side of the screen with 3 different objects on it. Imagine: health, combo and coins.
The thing is, if I create the object in a specific X or Y it goes away when changing the resolution. I tried to create them with this but doesn't work:
Create object "health" at: window.width/2 (middle one)
Create object "combo" at: window.width/2-(window.width/3) (left one)
But when It shows completely off because window.width takes the browser window and not the window size I wrote in the layout options. I tried every single full screen mode and nothing.
So: the object is created based on window width (1920 because of my monitor resolution) but the game is 720p.
Develop games in your browser. Powerful, performant & highly capable.
Have you tried putting the hud on a separate layer and setting the paralax of that layer to 0,0?
That is the standard way of creating a Hud..
Yes, I tried. The problem is that the object is created depending on the window width, not in the project resolution width. So for some reason, I create an object on window.width/2 and as my window is bigger (yes, it sounds veeeeery weird) the object actually shows on the right side of the screen. It's crazy.
Not at a computer right now but have you tried instead of window width taking the viewport right hand side and dividing by 2? I think its something like viewport.right. That should give you the actual position.
This usually gets the desired effect:
Where x = the number of the HUD-layer