Create object on point depending of resolution

0 favourites
  • 5 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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:

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

    Where x = the number of the HUD-layer

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)