ymobe / rapanui

High level API for MOAI framework
185 stars 48 forks source link

Detecting screen size problem #111

Open Sylph opened 11 years ago

Sylph commented 11 years ago

Basically, we know that line 47 RNFactory local screenX, screenY = MOAIEnvironment.screenWidth, MOAIEnvironment.screenHeight has changed to local screenX, screenY = MOAIEnvironment.horizontalResolution, MOAIEnvironment.verticalResolution on newer MOAISDK builds,

But this still doesn't take into account the status bar size in several devices I've tested (Archos 70 IT running Android 2.2) I have to replace line 75-76 RNFactory.width = lwidth RNFactory.height = lheight with RNFactory.width, RNFactory.height = MOAIGfxDevice.getViewSize()

to get the proper screen size so that the viewport doesn't overlap with the status bar on the archos, but it the bottom is still cut off when using HTC inspire (running Jelly Bean). I'll research more on this.

Sylph commented 11 years ago

It seems that at least on my android (2.2), MOAIGfxDevice.getViewSize() return 0 even at the beginning of RNFactory.init method, but on windows it only return a value after MOAISim.openWindow is called. The same behaviour happens with MOAIEnvironment.horizontalResolution and MOAIEnvironment.verticalResolution.

So changing the first part of RNFactory.init() to the following would make sure that the app can detect the screen size appropriately (taking into account status bars), at least for android and window host.

function RNFactory.init()
    local lwidth, lheight, screenlwidth, screenHeight
    local screenX, screenY = MOAIGfxDevice.getViewSize()

    if screenX ~= 0 then
        lwidth, lheight, screenlwidth, screenHeight = screenX, screenY, screenX, screenY
    else

I don't have access to an ios device right now to test that.

MattiaFortunati commented 11 years ago

Hi Sylph,

I've changed

if screenX ~= nil then

to

if screenX ~= nil and screenX ~= 0 then

this should work to fix the problem. Tested on my Android and iOS devices.

Thanks for the issue, sorry but on my Android the previous code worked well :D

Sylph commented 11 years ago

Yw. :) I'm using Unity3D at the moment, so i may not participate much anymore, anyway good luck. ^^

On Mon, Mar 25, 2013 at 8:30 AM, Mattia Fortunati notifications@github.comwrote:

Hi Sylph,

I've changed

if screenX ~= nil then

to

if screenX ~= nil and screenX ~= 0 then

this should work to fix the problem. Tested on my Android and iOS devices.

Thanks for the issue, sorry but on my Android the previous code worked well :D

— Reply to this email directly or view it on GitHubhttps://github.com/ymobe/rapanui/issues/111#issuecomment-15390381 .