IOS Fullscreen problems


(fedyfausto) #1

hello to all guys i have some problems with my game on IOS, i use this code for run in my computer very well in full screen but on ios don’t work correctly :frowning:

		private var screenwidth:uint = 888;
	private var screenheight:uint = 500;
	
	public static var opzioni:Impostazioni;
	
	public function Main():void
	{
		var scrWidth:Number;
		var scrHeight:Number;
		
		scrWidth = Capabilities.screenResolutionX;
		scrHeight = Capabilities.screenResolutionY;
		
		//do math to scale window to device size
		var scaledWidth:Number;
		var scaledHeight:Number;
		scaledWidth = (scrWidth / screenwidth);
		scaledHeight = (scrHeight / screenheight) //scaledWidth;//
		
		
		super(screenwidth, screenheight, 60, false);
					
		FP.screen.color = 0x000000;
	}
	
	override public function init():void
	{
		FP.console.enable();
		FP.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
		FP.stage.scaleMode = StageScaleMode.NO_SCALE;
		FP.stage.align = StageAlign.TOP_LEFT;
		//FP.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
		
		var guiSize:Rectangle = new Rectangle(0, 0, screenwidth, screenheight);
		var deviceSize:Rectangle = new Rectangle(0, 0,
		Math.max(stage.fullScreenWidth, stage.fullScreenHeight),
		Math.min(stage.fullScreenWidth, stage.fullScreenHeight));
		
		var appScale:Number = 1;
		var appSize:Rectangle = guiSize.clone();
		var appLeftOffset:Number = 0;
		var appTopOffset:Number = 0;

		// if device is wider than GUI's aspect ratio, height determines scale
		if ((deviceSize.width/deviceSize.height) > (guiSize.width/guiSize.height)) {
			appScale = deviceSize.height / guiSize.height;
			appSize.width = deviceSize.width / appScale;
			appLeftOffset = Math.round((appSize.width - guiSize.width) / 2);
		} 
		// if device is taller than GUI's aspect ratio, width determines scale
		else {
			appScale = deviceSize.width / guiSize.width;
			appSize.height = deviceSize.height / appScale;
			appLeftOffset = 0;
		}			
		
		if ((deviceSize.height/deviceSize.width) > (guiSize.height/guiSize.width)) {
			//appScale = deviceSize.height / guiSize.height;
			appSize.height = deviceSize.height / appScale;
			appTopOffset = Math.round((appSize.height - guiSize.height) / 2);
		} 
		// if device is taller than GUI's aspect ratio, width determines scale
		else {
			//appScale = deviceSize.width / guiSize.width;
			appSize.height = deviceSize.height / appScale;
			appTopOffset = 0;
		}	
		
		trace("scala:" + appScale + " Offsetleft:" + appLeftOffset + " Dimensioni:" + appSize.width + "x" + appSize.height);
		
	    trace("dimensione:" + stage.stageWidth + "X" + stage.stageHeight);
		
		GLOBALS.SCREEN_WIDTH = FP.screen.width;
		GLOBALS.SCREEN_HEIGHT = FP.screen.height;
		GLOBALS.FP_WIDTH = FP.width;
		GLOBALS.FP_HEIGHT = FP.height;
		GLOBALS.FULLSCREEN_WIDTH = stage.fullScreenWidth;
		GLOBALS.FULLSCREEN_HEIGTH = stage.fullScreenHeight;
		
		FP.screen.scale = appScale;

(Ultima2876) #2

What does it do? Got a screenshot?


(fedyfausto) #4

ok i fixed it :slight_smile: i only need a splash image for iphone 5 , if this don’t exist the iphone see the applicaztion fot iphone4 res