Question

I'm currently porting a Flash game to OUYA (an Android powered device) via Adobe Air.

Most of the work has been done already; it's packaged up and runs on Android devices.

However! It's stuck in a tiny corner on the screen, as seen in this picture

What I want is for the game to scale to the full size of the screen, while keeping the aspect ratio. I've seen other Flash to Air to Android games do this, so I know it's possible, I just don't know how.

Anyone have any tips? Thanks!

Was it helpful?

Solution

Read up on stage.scaleMode:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#scaleMode

That should be exactly what you need.

Another option to preserve aspect ratio is if you have a parent container that holds everything is scale it to fit yourself:

var widthRatio:Number = stage.stageWidth / BASE_WIDTH;
var heightRatio:Number = stage.stageHeight / BASE_HEIGHT;

if (widthRatio < heightRatio)
{
    container.scaleX = container.scaleY = widthRatio;
}
else
{
    container.scaleX = container.scaleY = heightRatio;
}

At that point you could either center the container to the stage:

container.x = (stage.stageWidth - container.width) /2;
container.y = (stage.stageHeight - container.height) / 2;

Or do something else with it.

OTHER TIPS

Turns out all I needed to make it work were these two lines of code:

stage.scaleMode = StageScaleMode.SHOW_ALL;
stage.align = "";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top