FlashPunk and Air 3.9 screen size issue


(SoggyBread) #1

I’m experiencing this weird issue with my app using AIR 3.9, when I use a preloader or set the main size to stage.fullScreenWidth and fullScreenHeight, the game becomes slightly over sized (it seems in just height) and won’t fit on the screen.

my stage default size in the project is 320,480 so I have no clue what could be the cause of this and wonder if anyone else can provide some insight.

Here’s my main function:

public function Main():void {

		super(320,480, 30, true);

		FP.world = new GameMenu;

	}

Here’s my preloader call to the main function:

private function run():void {

            nextFrame();

            var MainClass:Class=getDefinitionByName(mainClassName) as Class;
      if (MainClass == null) {

                throw new Error("AbstractPreloader:initialize. There was no class matching that name. Did you remember to override mainClassName?");
            }

            var main:DisplayObject=new MainClass() as DisplayObject;
            //trace(stage.stageWidth);

if (main == null) {

                throw new Error("AbstractPreloader:initialize. Main class needs to inherit from Sprite or MovieClip.");
            }

            addChildAt(main, 0);

			//main.width = stage.fullScreenWidth;

			//main.height = stage.fullScreenHeight;

        }

To top it all off, using fullscreen on my iphone causes the same issue, the game is slightly oversized, and it gets moved down for the iOS status bar. (I have systemChrome set to none)

Thanks in advance for any help.


(Alex Larioza) #2

Not entirely sure, but setting the stage size sounds like its going to affect how your game is rendered. Are you switching it back after the preloader? Also regarding the iPhone, I think Air automatically stretches the game to fit iPhone dimensions since your resolution is smaller your iPhone screen (unless you have a 3G/S).


(Ultima2876) #3

Try using stage.stageWidth and stage.stageHeight instead of stage.fullScreenWidth and stage.fullScreenHeight. :slight_smile:


(FNX) #4

For mobile apps what I do to go fullscreen is

FP.screen.scaleX    = screenWidth / FP.width;
FP.screen.scaleY    = screenHeight / FP.height;
FP.screen.smoothing = true; // optional

where screenWidth/Height is the mobile device fullscreen resolution, FP.with/height is the actual game size.

I hope this helps :slight_smile:


(SoggyBread) #5

I’ve tried every suggestion so far, and setting the size to stageWidth and stageHeight distorts the game a little while showing everything. Every other result does the oversize clipping issue

It doesn’t work on my iphone either, but apparently that’s a common iOS 7 issue right now. However, I haven’t read anyone having the issue with Fullscreen clicked and system chroma set to no.

I’m going to keep trying. here’s what I’m talking about:

screensize issue exampe

it’s clipped off on the bottom, driving me nuts.

here’s what it looks like on my phone

phone issue

this is all with the preloader off as well and just with Fullscreen clicked.


(Ultima2876) #6

Would it help if I post the scaling code I use for Stage3DPunk?

			var stageWidth: Number = Math.max(stage.stageWidth, 120);
		var stageHeight: Number = Math.max(stage.stageHeight, 80);
		
		if(enableAutoScaling == true)
		{
			var scaleFactor: Number = Math.min(stageWidth / FP.width, stageHeight / FP.height);
			if(enableSmoothing)	//any scale value will work with smoothing
			{
				FP.screen._stage3DscaleX = scaleFactor;
				FP.screen._stage3DscaleY = scaleFactor;
			}
			else
			{
				FP.screen._stage3DscaleX = int(scaleFactor);	//integer values only for better scaling in pixelly mode
				FP.screen._stage3DscaleY = int(scaleFactor);	//integer values only for better scaling in pixelly mode
			}
			
			FP.screen._stage3Dx = (stageWidth - (FP.width * FP.screen._stage3DscaleX)) / 2;
			FP.screen._stage3Dy = (stageHeight - (FP.height * FP.screen._stage3DscaleY)) / 2;
			
			trace("Autoscaling to " + stageWidth + "x" + 

stageHeight + "!");
}

You’ll want to make some adjustments there (eg using FP.screen.x instead of FP.screen_stage3Dx) but it should help you to scale whilst keeping ratio.