Create object on point depending of resolution

Get help using Construct 2

Post » Tue Aug 26, 2014 8:57 am

Hi!

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.
B
5
S
1
Posts: 34
Reputation: 512

Post » Tue Aug 26, 2014 11:14 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Aug 28, 2014 2:38 pm

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.
B
5
S
1
Posts: 34
Reputation: 512

Post » Thu Aug 28, 2014 2:48 pm

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.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Thu Aug 28, 2014 3:11 pm

This usually gets the desired effect:

ViewportLeft(x)+(ViewportRight(x)-ViewportLeft(x))/2

Where x = the number of the HUD-layer
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests