How to set individual device orientation for individual pages : Corona- SDK - orientation

I've made a game using Corona-SDK. It has 2 scenes: (1) Menu scene and (2) Game scene.
I need my app to be supported with two orientations : 'landscapeRight' and 'landscapeLeft'.
For that, I used the following lines of code in build.settings :
orientation =
{
default = "landscapeRight",
supported =
{
"landscapeRight", "landscapeLeft"
},
}
Unfortunately, this will affect the whole app.
But I want my game scene to be supported with only one orientation(eg: landscapeRight or landscapeLeft or in portrait).

Sorry, but Corona SDK does not have such capability.
What you can do is lock into one orientation, and places where you want to support more than one orientation, you can manually check the accelerometer to see if the phone is upside down, and then manually flip your graphics.
The most easy way to flip the graphics is put them all in a single group centered on the screen, and rotate that group 180 degrees.

Related

How to detect device rotation despite locked display orientation?

So I have an app that needs to not use autorotate. Instead of rotating the screen the buttons on the screen are just supposed to rotate.
I have the interface locked in landscape left. How do I detect what rotation the buttons should be?
I am using a custom opengl engine so I can set the rotation of objects.
You can get the device orientation from:
UIDevice.orientation
This is not the interface orientation, so you get two more possible values for face up and face down. Also the landscape left and right are swapped compared to UIInterfaceOrientation.
You can listen for changes in device orientation by subscribing to the UIDeviceOrientationDidChange notification from NSNotificationCenter. You may have to enable these notifications by calling UIDevice.beginGeneratingDeviceOrientationNotifications().
If the interface orientation is locked on the device, it is not listening to any delegate methods related to orientation changes.

Make some views independent to orientation change

How Can I make some of my UIViews to be orientation independent and some of them dependent. I'm looking for effect similar to this in standard iOS 9 Camera App when user change orientation from Portrait to Landscape. In Camera View Controller only left Icons and Right Icons are rotating but the internal view stays on position independently.

Game for Apple TV appears tilted on the big screen

Since a few years back I have a "iPhone is the controller, game screen displayed on TV by way of Apple TV and Air Play" project slowly going. It's like a space-shooter-maze kind of game, except there is no shooting and the objective is to steer a spaceship to find the boss (which is a pic of my then ~1 year old son). Like a NES game without the NES.
Now when I run the stuff for the first time in like a year or so, the controller, which is basically using a SpriteKit scene down the line, is tilted 90 degrees in the right OR left direction. The "OR" depends on what orientation my iPhone 6 Plus is in when the app starts. So the game only takes up half of the tv screen now - because it's tilted - and even a lay man can see that something fishy is going on because the text is not the normal horizontal text you are reading now, it's tilted.
Did something change recently, like with iOS 8 and how hooking up additional UIScreen:s work? I rarely touch this project, so I forget how everything work most of the time I do something with it again after a long hiatus. Anyone experienced this and know where to start digging?
Poking around, it seems that the app itself and what is displayed on the handheld device/controller (the iPhone) must/should be portrait only. If the app is launched in landscape mode, the screen display on the tv will also be "tilted", without the tv itself being tilted... and things get out of order. I set portrait only just by clicking around in the target->device orientation checkboxes.
This is kind of unwanted because the a normal video game controller is held in a landscape position and this was the way I always used it. I don't know what made this work differently, maybe it's the iPhone 6 Plus with landscape support at the home screen level, or maybe iOS 8 or whatever.
So there are basically two options here.
Design the controller as portrait, but already in the design put everything tilted. The bottom left steering cross would have to be put top left, tilted 90 degrees to the right for a fake "landscape right" setting. Might be less of a pain than doing the same thing to the tv screen instead.
Continue with the use of real landscape mode for the controller, and use some anti-tilt rotation by setting a new rotated transform of the tv controller's view's transform. (I tried this, it seemed like it needed a translation as well, so I gave up. Still might work.)
Update: I found a better solution:
Allow landscape right, landscape left AND portrait rotations of the app. (In that order, if you intend to launch the controller in landscape mode - but portrait has to be in there.)
In the subclass of UIViewController that controls what's going on upon your tv, return UIInterfaceOrientationMaskPortrait in supportedInterfaceOrientations. The tv controller must be run in "portrait" mode, which for a tv controller would mean the "default" mode, which for the eye looks like the normal landscapish mode. A landscaped tv controller would mean a tilted view, and we don't want that. Yes this is weird but maybe logical. Oh, and in the subclass of UIViewController for the hand controller, I return UIInterfaceOrientationMaskLandscape so as not to support portrait mode. The user likely launches the controller in portrait mode (especially on any iPhone other than 6 Plus) and if we supported that he/she would maybe think the controller can only be used in portrait mode, and that is very inconvenient when playing video games.

How to set different orientation for different screens in corona [duplicate]

I've made a game using Corona-SDK. It has 2 scenes: (1) Menu scene and (2) Game scene.
I need my app to be supported with two orientations : 'landscapeRight' and 'landscapeLeft'.
For that, I used the following lines of code in build.settings :
orientation =
{
default = "landscapeRight",
supported =
{
"landscapeRight", "landscapeLeft"
},
}
Unfortunately, this will affect the whole app.
But I want my game scene to be supported with only one orientation(eg: landscapeRight or landscapeLeft or in portrait).
Sorry, but Corona SDK does not have such capability.
What you can do is lock into one orientation, and places where you want to support more than one orientation, you can manually check the accelerometer to see if the phone is upside down, and then manually flip your graphics.
The most easy way to flip the graphics is put them all in a single group centered on the screen, and rotate that group 180 degrees.

How to rotate iOS MKMapView so that it north-oriented when switching tracking mode?

I am working on an iPad app (iOS 5.1), and I use MKMapView to display a map in my app.
I am switching between the three different map orientation modes using MKUserTrackingModeNone, MKUserTrackingModeFollow, MKUserTrackingModeFollowWithHeading and this works.
However I have a problem with the orientation of the map not resetting to north-facing orientation (north on the map being at the top of the screen) when switching from MKUserTrackingModeFollowWithHeading to MKUserTrackingModeNone.
On the built-in maps app on the ipad, the flow is like this:
When you start the app it is in mode MKUserTrackingModeNone and is north-oriented
When you toggle the orientation mode it changes to MKUserTrackingModeFollow, and the orientation is still north.
When you switch again, it changes to MKUserTrackingModeFollowWithHeading, and the map rotates according to the direction you are facing/pointing the iPad.
When you switch orientation again, it goes back to MKUserTrackingModeNone, and the map nicely rotates back to being north-oriented.
I would like my app to behave in the same way in regards to orientation when switching mode, but when I do as in step 4 above and switch from MKUserTrackingModeFollowWithHeading to MKUserTrackingModeNone, the orientation stays as it was just before making the orientation switch instead of rotating back to north orientation.
I am making the orientation switch with the standard MKUserTrackingBarButtonItem control placed in a toolbar.
Any ideas of how to solve this?
Thanks!
Are you using the standard iOS button bar item for doing this? My app does and as soon as I tap it from followWithHeading to non it rotates back to north is up.
This is a quick fix that works, though it's not very elegant:
https://stackoverflow.com/a/16576802/2077435

Resources