Viewport fit vs full-screen vs sprite scaling: still seeing borders

Not favoritedFavorited Favorited 0 favourites
  • 2 posts
From the Asset Store
Cute cartoon girl character with Walk, Jump, and Idle animations for 2D games.
  • Hi everyone, I’m struggling to get a single background Sprite to cover the entire screen on all aspect ratios (full-bleed), like CSS background-size: cover, without visible borders.

    What I have

    Project viewport: 1080x1920 (portrait)

    Background object: Sprite on a dedicated layer named Background

    Layer parallax: 0,0 (I also tried 100,100)

    I’m resizing the sprite to “cover” using this formula (works mathematically):

    On start of layout (and same on resized):

    Set bgW = BG_Egypt.ImageWidth

    Set bgH = BG_Egypt.ImageHeight

    BG_Egypt Set position to (ViewportMidX("Background"), ViewportMidY("Background"))

    BG_Egypt Set size to ( bgW * max(ViewportWidth("Background")/bgW, ViewportHeight("Background")/bgH), bgH * max(ViewportWidth("Background")/bgW, ViewportHeight("Background")/bgH) )

    Debug logs

    Example log values:

    VW=1334.23 VH=1920

    BGW=1334.23 BGH=2001.35

    So the sprite is larger than the viewport in one dimension (expected for cover), but I still see borders/letterboxing around the game area in preview / device emulation.

    Questions

    Is the correct solution to set Project → Viewport fit = Cover (instead of Auto) to avoid letterboxing entirely?

    Should the background layer parallax be 0,0 or 100,100 for a fixed background with camera?

    If Browser → Request fullscreen is triggered on On start of layout, it often fails due to user gesture restrictions. Could that cause letterboxing in preview even if scaling is correct?

    What is the recommended “best practice” to ensure a single background image covers the entire screen on mobile (Android/iOS/Web)?

    Any guidance or a minimal example would be appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is the correct solution to set Project → Viewport fit = Cover (instead of Auto) to avoid letterboxing entirely?

    No, the Viewport fit setting only controls whether the viewport extends into areas like the camera notch cutout on mobile devices.

    What you need instead is "Fullscreen mode" setting - set it to either Scale inner or Scale outer. That way the game will fill the entire screen, and you’ll be able to resize your background sprite accordingly.

    construct.net/en/tutorials/supporting-multiple-screen-17

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