Mobile Resolution help

  • Hi, which screen width and height should i use to create a portrait mobile game?
    Right now i`m using 1080x1920(Samsung Galaxy S4) but everything looks very small on screen.

  • I assume you have a version running on PC when you says everything looks small.
    There's 2 approaches to this:

    1. Use a game size relative to screen resolution.
    2. Scale everything in your game

    I use the latter in my game, scaling everything by a scale variable. Something like this:

    var scale = Lib.current.stage.stageWidth / FlxG.width;
    // for example
    text.size = * scale);

    I've made everything looks the same in every resolution by doing this. I'll show you the source code when I get home.

  • @DleanJeans Okay, thank you. Just to clarify it´s normal size on my pc but small on my phone.

  • Take a look at my Settings.hx file. It uses this to calculate the scale in portrait mode:

    _scale = FlxG.width / playField.width;

    You can replace playField.width with openfl.Lib.current.stage.stageWidth.

    Then I proceed to use scale to scale(?) some text sizes.
    The result is the text looks the same on both mobile and html5 build running on a mobile browser.

  • @DleanJeans Thank you for sharing your code! I think I've been able to integrate into my game.

  • doesn't haxeflixel already scale by itself?

Log in to reply