disable automatic screen rotation

212 views
Skip to first unread message

Phil Mexico

unread,
Jun 29, 2015, 5:10:25 PM6/29/15
to haxef...@googlegroups.com
Hello,

is there a way to deactivate haxeflixel's feature of automatically turn the screen upside down if accelerometer detects that a device is turned around?

I'm making an accelerometer controlled game and it's kind of getting into the way. I suppose I could invert the accelerometer control if the device is turned around, but I've been wondering about this, which would also be easier. On a side note, I frequently experience the game starting in portrait mode the first time I run a build on my phone if it is in portrait mode, screwing everything up, so I'm interested if the issue still occurs if I deactivate automatic orientation.

Thank you!

Gama11

unread,
Jun 30, 2015, 6:41:59 AM6/30/15
to haxef...@googlegroups.com, philipp...@googlemail.com
Autorotation is an OpenFL, not a Flixel feature.

Did you create your project using the default template? It has a line looking like this in the Project.xml:

<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />

 The orientation is set to landscape there.

SruloArt

unread,
Jun 30, 2015, 6:58:27 AM6/30/15
to haxef...@googlegroups.com, philipp...@googlemail.com
Plus you can directly change your AndroidManifest.xml "activity" tag's "screenOrientation" value to "landscape" instead of the default "sensorLandscape" that still lets your user to flip the orientation to the negative side (i.e from the bottom landscape to the upper landscape). You can read more about it here: http://developer.android.com/guide/topics/manifest/activity-element.html (under screenOrientation).

Thomas Bernard

unread,
Jun 30, 2015, 12:49:44 PM6/30/15
to haxef...@googlegroups.com
Funny. I am having the same issue and posted a new topic on this before I realized you already had it posted a few hours ago.
What kind of game are you developing Phil? (hope we did not had the same idea at the same time ;) )

Whatever, overriding AndroidManifest.xml with android:screenOrientation="portrait" fixed the issue for me. 
But I am wondering, what would be the behaviour on IOS platform? would it also switch upside down by default if orientation is fixed at "portrait" in the project.xml file? Also, on android, is there any other way to set screenOrientation to portrait without having to override the whole AndroidManifest.xml file?


On Monday, June 29, 2015 at 11:10:25 PM UTC+2, Phil Mexico wrote:

Phil Mexico

unread,
Jul 2, 2015, 6:02:38 PM7/2/15
to haxef...@googlegroups.com, philipp...@googlemail.com
Oh dear... yes, that explains a lot of things.

Thanks a lot for your help! I haven't figured it out just yet, but now I know where to look.


@Srulo: Yes, I am using the default template. It does say "landscape" instead of "sensorLandscape", so if I understand things correctly, it already should ignore sensor output for orientation - however, it doesn't seem to make a difference which one I chose. From what I gather, it seems that Project.xml is overwritten by OpenFl; Thomas wrote a post in the forum there: http://community.openfl.org/t/fix-orientation-to-portrait-rather-than-sensorportrait-on-android-without-overriding-androidmanifest-xml/1735

@Thomas: I'm developing an autoscroller in which you have to collect or evade objects coming towards you, and you can control it via touchscreen or touches on mobile devices. I would be surprised if it was the same game - but I'd be happy to go more into detail so we can help each other - PM me if you're interested. Or anyone else; just don't want to spam here.

Again, thanks everybody!

Thomas Bernard

unread,
Jul 6, 2015, 9:02:12 AM7/6/15
to haxef...@googlegroups.com

@Srulo: Yes, I am using the default template. It does say "landscape" instead of "sensorLandscape", so if I understand things correctly, it already should ignore sensor output for orientation - however, it doesn't seem to make a difference which one I chose. From what I gather, it seems that Project.xml is overwritten by OpenFl; Thomas wrote a post in the forum there: http://community.openfl.org/t/fix-orientation-to-portrait-rather-than-sensorportrait-on-android-without-overriding-androidmanifest-xml/1735

Project.xml is not overwritten by openfl. This is the AndroidMAnifest.xml file that is automatically created by openfl according to the project.xml content. Sadly, there is currently no option in project.xml to differientiate "landscape" to the "sensorLandscape" case (the "landscape" option of project.xml is automatically translated into "sensorLandscape" when building for android). That is the reason why, if you want to force the orientation to android "landscape", you have to overwrite AndroidManifest.xml (copy the one automatically created by openfl in "/export/android/bin" when you build your project. Change it to suit your needs and place it into a "/templates" directory (or whatever name you want to give to it). Then in your project.xml file, add the line : <template path="templates/AndroidManifest.xml" rename="AndroidManifest.xml" />  before loading flixel. And it should work ;)  )

 
@Thomas: I'm developing an autoscroller in which you have to collect or evade objects coming towards you, and you can control it via touchscreen or touches on mobile devices. I would be surprised if it was the same game - but I'd be happy to go more into detail so we can help each other - PM me if you're interested. Or anyone else; just don't want to spam here.

I am actually developping a 3D maze in wich you control the marble with the accelerometer. So it is definitively not the same game ;) . 
 

Phil Mexico

unread,
Jul 8, 2015, 3:21:06 PM7/8/15
to haxef...@googlegroups.com
Wow, great, that was exactly what I was looking for!

Many many thanks!!!
Reply all
Reply to author
Forward
0 new messages