How to determine center of screen from viewportWidth in fullscreen mode Scale Outer?

0 favourites
  • 3 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • I have shifted to scale outer from letterbox and have observed some unexpected behavior when working with the variable viewportWidth.

    I have a viewport size of 1080 x 1920 (9:16 aspect ratio). When I have a window that is wider than this, the variable viewportHeight stays fixed at 1920 and viewportWidth returns some value say 4000.

    What I am struggling with is to utilize the viewportWidth to calculate the center point and set the position of an object to this point.

    During letterbox mode this would be 540, 960 and now it is ? , 960. When testing, it appears the center to be something around the 300s when stretch to a width around 4000. How do I calculate this? I did not see an immediate relation ship to the aspect ratio jumping out at me.

    Perhaps there is a much simpler way for reliably determining the "center" when in scale outer to position objects relative to it.

    Any help is appreciated!

  • I ended up working around this by not relying on the viewportWidth. In general, utilizing my viewport size of 1080 / 1920, i hard coded my variables off of center points of 540 960 and it all seems to be working.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure exactly what you're doing based on that description, but a common mistake is to use ViewportWidth("Layer") / 2 for the middle of the screen. That's incorrect, it just gives you half the viewport width, which doesn't take in to account scrolling. The middle of the viewport is (ViewportLeft("Layer") + ViewportRight("Layer")) / 2.

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