I'm working in an app with Starling Framework but I have a problem, the application works in almost every kind of device, but when I try to install it in a Galaxy Tab 2, appear some problems because the default orientation is landscape so the application looks totally disorganised. I tried to modify this with the XML and adding an event to do the orientation manually but it doesn't work, so I need help.

First I made was this

<aspectRatio>portrait</aspectRatio>
<autoOrients>false</autoOrients>
<fullScreen>true</fullScreen>
<visible>true</visible>

After I tried with this

 stage.setOrientation( StageOrientation.UPSIDE_DOWN );

Thank you so much!

有帮助吗?

解决方案

StageOrientation.UPSIDE_DOWN is 180 degrees from StageOrientation.NORMAL, so if normal is landscape then upside down is also upside down and some devices don't support that. I would suggest using height and width to determine the absolute orientation rather than the relative and react to that

if (stage.width > stage.height)//we are in landscape
{
    if(stage.orientation == StageOrientation.NORMAL || stage.deviceOrientation == StageOrientation.NORMAL)
    {
        stage.setOrientation(StageOrientation.ROTATED_LEFT);
    }
    else
    {
        stage.setOrientation(StageOrientation.NORMAL);
    }
}

Also it's worth noting that there is a difference between stage.orientation and stage.deviceOrientation you can read about this in more detail here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top