Android fullscreen resolution without croping it out



  • Hello, i recently added a static background to my android game menu, i have my project.xml set to full screen But it crops some part of the image to fit. I want to it scale to my screen resolution without cropping anything out and any other android screen resolution.



  • @ttt

    Hi,

    You can try setting scale mode. There's a demo here -> https://haxeflixel.com/demos/ScaleModes/

    import flixel.system.scaleModes.FillScaleMode;

    FlxG.scaleMode = new FillScaleMode();

    This scale mode will stretch the game to fit the screen and you won't have the letterboxing. If the device resolution is much different than the size your game is designed in, it might not look great when stretched. This affects the whole game.

    If you only want to stretch the one background image I think you can use myBgImage.setGraphicSize(FlxG.width, FlxG.height);

    https://api.haxeflixel.com/flixel/FlxSprite.html#setGraphicSize

    Hope it helps. Designing for mobile has its challenges. There are so many different resolutions.



  • @ttt

    also, make sure in Project.xml you set the window size to 0.

    <window if="mobile" width="0" height="0" fullscreen="true" />



  • @dean the background is actually bigger than my screen resolution.



  • @dean and i want it to scale automatically.



  • @ttt

    This doesn't work?

    myBgImage.setGraphicSize(FlxG.width, FlxG.height);

    Maybe I don't understand.



  • @dean No, what i mean is i want it to scale without pressing keys or anything. The link you gave me is with a condition of pressing space bar.



  • @ttt

    Where ever you add your background image you can size it there.

    var bg = new FlxSprite();
    bg.loadGraphic("assets/images/bg.png");
    bg.setGraphicSize(FlxG.width, FlxG.height);
    bg.updateHitbox();
    bg.scrollFactor.set();
    add(bg);
    

    The scale mode demo is for the entire game, in case you want to make it stretch to fill the whole screen.
    In that case, you can do it in Main.hx:

    import flixel.FlxG;
    import flixel.system.scaleModes.FillScaleMode;
    
    // add this in new() { }
    FlxG.scaleMode = new FillScaleMode();
    

Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.