Copy link to clipboard
Copied
A game that I'm working on is set at 640x360. For the desktop version, I allow the user to double or triple the size of the window. This can be done easily by using Stage.nativeWindow.width and Stage.nativeWindow.height. I don't have to worry about scaling since everything scales up to fill the entire window when the resizing occurs.
I'm having difficulty figuring out how to scale this 640x360 game to fill the entire screen of a mobile device. There is no option in copyPixels that allows me to scale before blitting, so if I wanted to resize my game to fill the screen on a phone, I believe that my best bet would be to manually scale everything to fill the screen while keeping the aspect ratio intact.
640x360 is a 16:9 aspect ratio. My Nexus 4 lies somewhere between 15:9 and 16:9. So, if I scale my game to fill the Nexus' screen, it would end up being a little wide. To center it, everything would have to be moved a bit to the left (the sides would be cut off, which is fine).
Is there a way to manually control the built-in scaling system (the one used to automatically resize everything in the desktop version) to resize everything according to a scale that I calculate and then center everything on the screen?
Is what I am trying to do even possible, or should I be taking a different approach?
Copy link to clipboard
Copied
Years ago I found that the native stage scale in Flash is not very reliable and discovered that using fullScreenSourceRect as a kind of mediator gave me better results.
can´t be sure though that it works in AIR on mobile. Maybe its worth a shot?
function goScaledFullScreen() {
var screenRectangle:Rectangle=new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
stage.fullScreenSourceRect=screenRectangle;
stage.displayState=StageDisplayState.FULL_SCREEN;
}
Copy link to clipboard
Copied
This is pretty much what I was looking for. Unfortunately, it only works on the desktop, not on mobile (or at least, not on Android). I did find something that worked - ScaleMode.NO_BORDER. It scaled everything up, centered things, and cut off whatever was to the right and left in order to keep the original aspect ration intact.
Copy link to clipboard
Copied
draw() or drawWithQuality() allow you to use a transformation matrix. Because they're slower than copyPixels(), you may want to consider creating an initial resource using one of the draw methods and thereafter using copyPixels().
Copy link to clipboard
Copied
Thanks for the suggestions. I will try using draw(). If there is a noticeable performance hit, I will try creating a new BitmapData and drawing a resized version of the entire spritesheet onto it so that I can continue using copyPixels().
Find more inspiration, events, and resources on the new Adobe Community
Explore Now