Lib.current.stage.window.width VS Lib.current.stage.stageWidth


#1

So,I have some code like this, which I have happily cope/pasted from Joshua:

public static function winWidth():Int
{
	var width:Int = Lib.current.stage.window.width;
	
	if (width > 0)
		return width;
	else
		return Lib.current.stage.stageWidth;
}

But suddenly, it stopped working properly in iOS 12.1 (or is it OpenFL problem?).

Lib.current.stage.window.width now returns only half of the screen size (same for height), why? :slight_smile:
What should I use, that will always give me correct screen size?
Thank you!


#2

Try:

window.width * window.scale

Scale will return 2 or greater on an iOS retina device :slight_smile:


#3

Can I use Lib.current.stage.stageWidth instead everywhere?
Or whatโ€™s the difference between those two?


#4

And is Lib.current.stage.stageWidth the same as Lib.application.window.width?


#5

stageWidth is the same as window.width * window.scale when the OpenFL stage is resizable, otherwise stage width and height are constant