Changing the position of the game on Mobile with Ratio/Fixed scaling?

57 views
Skip to first unread message

Andrej

unread,
Oct 22, 2014, 9:44:09 PM10/22/14
to haxef...@googlegroups.com

When using the Ratio or Fixed scaling modes on mobile devices, chances are that there will be some black bars around the game. By default, the game is centered in the middle of the display; is there a way to change that position so that the game is for example aligned at the top of the screen? Couldn't find anything in the docs, the FlxGame constructor doesn't take any position coordinates and FlxGame.cpp goes over my head a bit :/ I only need this for Android and iOS.

SruloArt

unread,
Oct 23, 2014, 5:41:38 AM10/23/14
to haxef...@googlegroups.com
Do you have any specific example of what you want to achieve (an image preferably)? there's FlxG.game.x/y (also on the FillScaleMode), the RatioScaleMode takes a fillScreen:bool, there's a StageSizeScale mode...

Andrej

unread,
Oct 23, 2014, 7:02:28 AM10/23/14
to haxef...@googlegroups.com

This is what I want it to look like when playing on an Android device:



This was done in HTML5; the game screen + the controls are the canvas and the Super Oh Boy device graphics to the left, right and bottom of it are a background image done with CSS. While converting this to HaxeFlixel, I've figured out that I can add a background image in Main.hx using OpenFl (just by adding bitmaps, they will be rendered below the game proper since it's instantiated afterwards), now I just need to move the FlxGame upwards so it's at the top of the phone screen. FlxG.game.y sounded like what I needed, but it didn't really do anything...?

SruloArt

unread,
Oct 23, 2014, 8:27:39 AM10/23/14
to
You can use your own PixelPerfectScaleMode where you override the updateGamePosition().

Andrej

unread,
Oct 23, 2014, 9:08:20 AM10/23/14
to haxef...@googlegroups.com
Indeed I could! Thanks a lot, that did the trick.

On Thursday, October 23, 2014 2:27:39 PM UTC+2, SruloArt wrote:
You can use your own PixelPerfectMode where you override the updateGamePosition().


On Thursday, October 23, 2014 2:02:28 PM UTC+3, Andrej wrote:
Reply all
Reply to author
Forward
0 new messages