Scale game page for mobile browser

  • Hi!

    I've created a simple app and it works fine in desktop browser

    But when i try to launch it in mobile browser I get the following
    alt text

    Is there any way to scale app or app page in mobile browser?

    Would it work for preloader? As far as I understand preloader works with just openfl

    Thanks in advance!

  • Try setting the size window width and height to 0 in Project.hxml:

    <window if="html5" resizable="false" width="0" height="0" />

  • Thanks a lot! That works for mobile, but desktop browser expands my game to the whole browser window. While I'd like to keep it in certain sizes, say WxH

    The idea is the following: I want to keep game size WxH in desktop browser (until browser window size are less than game size) and scale game size to scaleW x scaleH keeping the ratio of height and width in mobile browser (when browser window size are less than game size).

    I come up with js.Browser.window.innerWidth/height possible solution, but I'm not sure whether it would work and it seems tedious.

    Perhaps there is a simple way to detect entry from mobile browser and use it Project.xml

  • @kpded

    something like this.

    <window width="960" height="540" fps="60" background="#000000" hardware="true" vsync="true" />
    <window if="mobile" width="0" height="0" />

  • @kpded

    After reading that again, I don't think that's what you're looking for. ^ Sorry, I don't have an answer for you.

  • Maybe add this to your Main.hx:

    	var width = 800; // your W
    	var height = 600; // your H
    	if (FlxG.onMobile) {
    		width = Lib.current.stage.stageWidth;
    		height = Lib.current.stage.stageHeight;
    	addChild(new FlxGame(width, height, PlayState));

  • @DleanJeans
    Thanks, FlxG.onMobile() works perfectly!

Log in to reply

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