Centered objects don't really work in different resolutions

0 favourites
  • 5 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • ello I have a problem with my centered object,

    My project window size is 854 x 480

    I've tried to use > ViewportLeft("Hud")+ViewportRight("Hud")/2 for the object

    it worked perfectly on my redmi 4x phone which has 1280 x 720 resolution (16:9 ratio)

    but the problem is, it didn't work perfectly on my redmi note 8 phone which has

    2340 x 1080 resolution (16:9 ratio), the object wasn't perfectly centered

    I've also tried to change the ViewPort Layer from "Hud" to another layer, and yeah it affects the object position, but still didn't make the object perfectly centered

    do you guys have any idea what should I do ??

    Thankss

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, forgot to tell this is the object I mean

  • And sorry i meant my redmi note 8 resolution ratio is 19.5:9

  • ViewportLeft("Hud")+ViewportRight("Hud")/2

    This calculation is incorrect - division has higher precedence than addition so it will actually calculate ViewportLeft("Hud") + (ViewportRight("Hud") / 2). If you want the mid-point you need to use (ViewportLeft("Hud") + ViewportRight("Hud")) / 2.

  • > ViewportLeft("Hud")+ViewportRight("Hud")/2

    This calculation is incorrect - division has higher precedence than addition so it will actually calculate ViewportLeft("Hud") + (ViewportRight("Hud") / 2). If you want the mid-point you need to use (ViewportLeft("Hud") + ViewportRight("Hud")) / 2.

    OMG yeahh just missed the Parenthese!

    Thank you so much! you're a lifesaver!

    it's now perfectly centered!

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