Correct math for converting PlatformInfo.SafeArea to Project Pixels (1080p Scale Outer)?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Construct 3 educational game that renders real mathematical expressions
  • Hello.

    I am working on a mobile game with a project resolution of 1080x1920 using Scale Outer.

    I need to position UI elements to avoid the "Notch" or "Dynamic Island" using PlatformInfo.SafeAreaInsetTop. To convert this value to layout coordinates, I am currently using:

    PlatformInfo.SafeAreaInsetTop*(1080/PlatformInfo.WindowInnerWidth)

    Is this the correct way to get the in game pixel height for the notch?

    There is also PlatformInfo.DevicePixelRatio. Maybe I should multiply it with that?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • By default Construct layout co-ordinates line up with CSS co-ordinates. So unless you apply some sort of scaling to the layout/layer yourself, I think the safe area size should just be used as-is.

  • Here is the height PlatformInfo.SafeAreaInsetTop gives for a pixel 7. The value I'm getting is 42 which is way too small.

    Here is the height provided by my formula: PlatformInfo.SafeAreaInsetTop*(1080/PlatformInfo.WindowInnerWidth). PlatformInfo.WindowInnerWidth is 411. Meaning if I do 42*(1080/411) = 110 which looks to be exactly correct.

    I don't really understand why its correct though and if its safe to use.

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