1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [SOLVED] Resizing view to prevent black bars (on mobile devices)

Discussion in 'Programming' started by Doug, Aug 13, 2017.

  1. Doug

    Doug Guest

    Post #2 has links to tutorials
    Post #5 has amendments to tutorial to make it work

    Hi everyone,

    I'm struggling with a process that someone may be able to help with. I've followed many tutorials, looked at many forums, but unfortunately I've been unable to find what I'm looking for.

    I'm creating a game for Android. My current phones to test it on are a Galaxy S6, Moto E and Moto G 2nd Gen. All of these phones have the same aspect ratio, 16:9, and I wish for my game to work on tablets with 4:3 ratio without black bars (well any other ratio really!). The view is currently 1024w 576h, and the rooms are much larger than the view.

    I believe I understand that the best way of doing something like this is to:
    • Lock one of the views (say, lock the 1024 width, as the game depends on a specific width to be maintained), then change the height according to the new aspect ratio i.e. change the original 576 (16:9) to 768 (4:3), without stretching (just view more of the room instead, preventing black bars at the top and bottom).

    Annoyingly, I cannot for the life of me work out how to do this! Is someone able to help, please?

    Thank you very much in advance!
    Last edited by a moderator: Aug 13, 2017
  2. chamaeleon

    chamaeleon Member

    Jun 21, 2016
  3. Matt Hawkins

    Matt Hawkins Member

    Jan 29, 2017
    In global game settings open the android/fire tab, then graphics tab and select Full Scale.
  4. RangerX

    RangerX Member

    Jun 20, 2016
    This is will NOT change its view size. It will only stretch what he have. (and look horrible)
  5. Doug

    Doug Guest

    Thanks chamaeleon.

    I found Pixelated Pope's guide earlier and tried to work from that. It wasn't working for so long, but when I deleted:

    if (display_height mod ideal_height != 0)
        var d = round(display_height/ideal_height);
    if (display_width mod ideal_width != 0)
        var d = round(display_width/ideal_width);
    It started working as intended, and extends the view/camera's height for all aspect ratios (and keeps the width as it is). Just for the record, the most popular aspect ratios among android devices are:

    Thanks a lot, I'll marked the post as solved.
  6. Pixelated_Pope

    Pixelated_Pope Member

    Jun 20, 2016
    Not sure what you mean by "wasn't working" but that part of the code is the "perfect scaling" code which changes your ideal width and height to be a factor of the display's width and height. Glad you got it working, though.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice