CSS Background image on iOS export

0 favourites
  • 5 posts
From the Asset Store
Shark.io
$49 USD
Shark.io in the sea full of killer sharks, Sunday of life is the game. Who knows what is happening under the sea?
  • Hey everyone,

    I have created a game in "letterbox scale" fullscreen format.

    As I wanted to make better use of the unused areas, I inserted a responsive background image using CSS.

    default.css:

    body{
     background: url('paper_background.png') no-repeat center center fixed; 
     	-webkit-background-size: cover;
     	-moz-background-size: cover;
     	-o-background-size: cover;
     	background-size: cover;
    	height: 100% ;
    }

    When exporting for Android, the paper background looks as expected.

    When exporting for iOS (XCode), you can see the background shining through, but it is apparently covered by a white background.

    Does anyone have any idea how I can get this to work for iOS?

    Thank you very much!

    Sascha

  • Hmm I can't tell what could possibly be wrong but why even bother adding it via CSS? You should be able to just add the image as a tiled background, with maybe a little bit of tinkering with the Anchor plugin so it scales properly to the screen size. construct.net/en/make-games/manuals/construct-3/behavior-reference/anchor

  • Thanks for the reply! I did not use the anchor behavior yet. This also works for "letterbox scale" mode? Beacuse this is why I went the CSS route to avoid the black bars.

    Overall it still seems easier to just insert these few lines of CSS code instead of repositioning all of my game objects ... if only it would work for iOS.

  • Oh you want to avoid the black bars... I dunno if theres really a way around changing the scaling mode. You probably could go with "scale outer" and just strech the background out a bunch without changing the position of your game objects. Or maybe "scale inner" works better in your case?

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

    Unless you somehow figure out why the css doesn't work. Perhaps there's some specific css property you have to set for ios or something in xcode? Maybe the url path is different on ios and it just loads a white image? Maybe try url('./paper_background.png')

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried to change the url location to url('./paper_background.png'), but still the same effect.

    However, if I completely delete the image file, the background gets plain white.

    This confirms my original assumption that the background image is indeed displayed, but iOS puts a slightly transparent white background over it for some reason.

    I guess it's just something I could fix in Xcode, but I don't know where ...

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