Android Menu Bar affects rendering?

26 views
Skip to first unread message

ThunderXBlitZ

unread,
Nov 3, 2015, 7:05:00 AM11/3/15
to HaxeFlixel
Does the android menu bar (home button etc) affect rendering? Seems to me like it does

My device's dimensions in pixels is 2560 x 1440.


In my state, i drew a 640x480 red rectangle to represent my game stage. Main gameWidth: 640, gameHeight:480
automated zoom ratio = 3.  (1440/480)

To auto-center my stage, i shifted FlxG.camera.x by (Lib.stageWidth  - (640*3)/2, which i assumed would work.
 However, it was only centered factoring in the android menu bar.

Checked my values, Lib.stageWidth = 2560 after targetting android sdk 19.

Can anyone figure out the problem? Or does rendering take into account the android menu bar by default?
My main purpose is to be able to auto-centre the game screen as it seems haxeflixel scales up the game to fit the device screen, it is aligned to TOPLEFT, resulting in white space on the left/bottom,
if anyone can teach me how to do that, that will be great too

Thanks!


SruloArt

unread,
Nov 3, 2015, 10:23:29 AM11/3/15
to HaxeFlixel
* OK, this is a pretty complicated subject.

* The gist of it is that HaxeFlixel uses a scale modes concept to scale your entire game on whatever stage size that's available (It's not the Flash API scale mode mind you).

* The default FlxScaleMode is Ratio. Check here to see what the available flixel's scaleModes mean:  http://haxeflixel.com/demos/ScaleModes/

* Your current game's ratio (640/480) isn't suitable to work with your device ratio (well, at least without empty spaces), so you would have to change the default scale mode to something more befitting.

* How? just look at the code, try different things, it's all very logical.

* p.s your stage is actually an OpenFL stage, meaning you don't normally specify a resolution on mobile (width = 0, height = 0 in your project.xml).

* p.s The HaxeFlixel Lib defaults are noScale (scaleMode) and Top_left (align) and can be easily changed.

* p.s.a So don't use the FlxCamera for moving what you think is the stage, because it's not.

* p.s There's an event resize being fired repeatedly to check for stage size changes and to scale the game accordingly. As long as your menu bar appears on screen (http://developer.android.com/training/system-ui/navigation.html) your stage size would factor it in.

MegaLeon

unread,
Nov 3, 2015, 10:45:23 AM11/3/15
to HaxeFlixel
Adding on top of SruloArt's excellent answer, you can enable immersive sticky mode (aka getting rid of the menu bar when your game is playing) in HaxeFlixel like this: https://gist.github.com/leoncvlt/f398e629ec1ca5bad9b0
Reply all
Reply to author
Forward
0 new messages