Screen Orientation


(Nate ) #1

Hey guys! I am attempting to set up a base AIR Mobile AS3 application in FD using FP as well.

I am just testing the waters, and I was going to make a simple side-scroller test game. For this I need the screen orientation to be forced to the left. Here is what I have so far:

package {
import flash.desktop.NativeApplication;
import flash.events.Event;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;

import net.flashpunk.Engine;
import net.flashpunk.FP;
import flash.display.StageOrientation;

[SWF(width="800", height="480", frameRate="30")]


public class Main extends Engine
{
	
	public function Main()
	{
		super(800, 480, 30, false);
		
		StageOrientation.ROTATED_LEFT;
		stage.scaleMode = StageScaleMode.EXACT_FIT;
	}
	
	private function deactivate(e:Event):void 
	{
		NativeApplication.nativeApplication.exit();
	}
	
}
}

I have made applications for my phone before which were all portrait and used the reverse width and height, 480x800 which is my screen size. However I would like to force landscape now.

Any input would be greatly appreciated! Thanks guys


(Nate ) #2

Okay I have the screen orientation forcing landscape, and I did that by un-commenting a line in the .xml file!

My next question is this… I set the background to be blue so you can see what I am talking about. When I test it on my computer it takes up the full window and it is oriented properly.

On my device it orients correctly however it does not take up the entire screen. Image and video hosting by TinyPic

Do I have to jack up the width and height?


(Nate ) #3

FIXED… I think…

So I just changed the size of the width and height to the exact size of my phones screen and it seems to have worked… I feel ashamed… lol

If there is a better way to do this, such as have something in place to be able to autosize across other devices please let me know!

Thank you!


(Kyuur) #4

To adjust width and height for any device:

   	width = flash.system.Capabilities.screenResolutionX;
        height = flash.system.Capabilities.screenResolutionY;

Should work. Of course your game logic will need to reflect this change in resolution. If you don’t mind graphical stretching you may prefer to set the scaleX and scaleY to the capabilities divided by your screen size.


(azrafe7) #5

When you’ll get to content scaling on different devices you’d probably want to have a read of this article which I found really helpful.


(Nate ) #6

Okay guys! Thanks a lot! I actually have another question… So basically when I test it on my computer it looks like the first image, but when I play it on my phone it still does not seem to want to fill the screen out the way it does on my computer. Also don’t mind the different background colors, I have the background using a random seed. Also the ugly buttons are just placeholders! So is the character! lol

How it looks on my computer: Image and video hosting by TinyPic

How it looks on my phone: Image and video hosting by TinyPic

As you can see my phone is doing some kind of odd scaling and I am not sure what I have to change… oddly though… I accidentally left the console enabled when I did a debug build for my phone and as you can see the console knows where the window is… Am I just having issues because on my computer what I am editing is getting lost in translation in terms of the X and Y values of things?

Thanks for any input guys!


(Nate ) #7

It appears as if though… I needed to changed the Debug window dimensions in the Run.bat… I just did and it LOOKS like I have it working now.