Skip to main content
leoserra
Inspiring
January 27, 2015
Question

mobile screen detection and scaling

  • January 27, 2015
  • 2 replies
  • 486 views

Hi,

Hopefully I'm in the correct forum, but feel free to direct me otherwise.

I'm been developing a small and simple game targeted to mobile devices.

I've just finished all the logic, so now I'm more focused on the graphics part. My first dilemma is to understand how to resize the game to have the same aspect, on basically any mobile screen in the portrait mode.

I'm using a 480x850 stage in Flash and calling a document class that I'm developing in FlashDevelop.

The interesting thing I saw was that if I use the methods to detect the screen size, I can't make the game appear correctly. Some objects will show very big and/or outside the screen boundaries. The positions that are randomly generated are based on the following code:

_stageWidth = Math.min(stage.fullScreenWidth, _screenBounds.width);

_stageHeight = Math.min(stage.fullScreenHeight, _screenBounds.height);

Running in Flash, these give me what I have 480x850 (expected). When running on the device (HTC ONE M8) returns 1080x1776 (360dpi) [according to GSMArena this has 1080x1920-441dpi] and objects will completely or partially be off screen.

If I use the following code:

_stageWidth = Math.min(stage.fullScreenWidth, _screenBounds.width, stage.stageWidth);

_stageHeight = Math.min(stage.fullScreenHeight, _screenBounds.height, stage.stageHeight);

It returns the dimensions of the stage in Flash which works well for this purpose.

I guess my questions are:

1. Since I have enabled the "fullscreen" in the AIR settings in Flash, and I get the total available screen size from the phone and make the objects positions based on that, why do objects go beyond the visible boundaries?

2.Maybe it has something to do with the DPI, but how can I calculate the correct positions for these?

I'm using AIR 15 on Flash CS6.

I have checked this article which basically explains it, I find my results confusing.

Thanks!

This topic has been closed for replies.

2 replies

leoserra
leoserraAuthor
Inspiring
January 27, 2015

Thanks for the insight Wade.

I can see what you mean. What I find weird is that, although the phone has a "massive" screen, it seems that something is wrong when translating the coordinates in the code, to the "real world" of the screen. Even if the coordinates are generated inside the parameters of the screen, the objects might be cutted if they "fall" out of the screen dimensions.

In the meantime I managed to solve this by adding the following lines in the ADDED_TO_STAGE event:

stage.scaleMode = StageScaleMode.NO_SCALE;

stage.align = StageAlign.TOP_LEFT;

Maybe a beginners issue

I'll be trying at home with a SonyEricsson XPeria Arc S, that has physical buttons and check how it goes.

I'll keep the thread updated.

January 27, 2015

Can you provide screenshots of your app so it can be seen where the assets are going off the screen?

I think some of this might be a bug with AIR for Android. Since some Android phones have onscreen buttons, like your HTC One, the full pixel height of the device is not necessarily the available pixels. The 1776 pixels tall you got reported is probably the 1920 minus the height of the onscreen button area. But since it is in "fullscreen", the app may be eating into that area and that could be what is throwing it off. But this is really just speculation/guessing until we can see pictures of the issue at hand. I haven't done any fullscreen Android apps because I was afraid of issues like I just speculated above based on how the newer versions of Android operate.

Edit: I have a Nexus 5 and it also has a 1080x1920 screen resolution. I just took and screenshot in portrait view with the onscreen buttons having a solid black background and measured the height. It came out to 144, which is what you get from 1920-1776.