get wrong iOS device resolution

339 views
Skip to first unread message

Trieu Tran Quoc

unread,
May 10, 2015, 12:52:57 PM5/10/15
to haxef...@googlegroups.com
Hi all,
I added <window width="0" height="0" if="mobile" /> to Project.xml and use the following code to get device resolution:
var stageWidth:Int = Lib.current.stage.stageWidth;
var stageHeight:Int = Lib.current.stage.stageHeight;
It works fine on android device, stageWidth and stageHeight value are correct.
But on iOS device and simulator, stageWidth and stageHeight value are incorrect, I tested on iphone 4s (both device and simulator), I saw stageWidth=320, stageWidth=480 (not 640x960).
Please help me resolve this problem, thank you very much.
I used some lib:
flixel: [3.3.8]
openfl: [3.0.3]
lime: [2.3.3]

SruloArt

unread,
May 11, 2015, 3:48:48 AM5/11/15
to haxef...@googlegroups.com

(https://github.com/HaxeFlixel/flixel/issues/1425): "This is old. The problem is that on iOS 6/7/8/+ there's a very short delay before the Event.Resize is fired, so you're left with the non-retina values for your stage until then. This is why you see so many OpenFL projects do this":

#if ios
haxe.Timer.delay(init, 100); // iOS v. > 6
#else
init();
#end

In other words, just change your Main so it would have a small delay when you run on iOS (like so: https://github.com/Tiago-Ling/flixel-templates/commit/189f14223312d3302e6fd1bf43aee6aa445dc34b) and you should be fine.

Trieu Tran Quoc

unread,
May 11, 2015, 12:31:44 PM5/11/15
to haxef...@googlegroups.com
I did as you said above, but it doesn't work for me, event if I change 100->1000 or 10000 :(

SruloArt

unread,
May 12, 2015, 3:55:20 AM5/12/15
to haxef...@googlegroups.com
The event is your problem, you can try solewalker's solution (in the github's issue 1425 thread I've linked).

SruloArt

unread,
May 12, 2015, 3:55:26 AM5/12/15
to haxef...@googlegroups.com
The event is your problem, you can try solewalker's solution (in the github's issue 1425 thread I've linked).

Trieu Tran Quoc

unread,
May 12, 2015, 9:40:31 PM5/12/15
to haxef...@googlegroups.com
It works for me, thank you very much :)
Reply all
Reply to author
Forward
0 new messages