SOLVED: Animated autorotation in Graphics 2.0 not possible

In previous versions of Corona I have code that will animate the rotation of the stage around the center-point when the device orientation changes.

With Android I don’t need to add special coding since the OS handles this quite nicely. On Android < 4.0 you have “instant rotation” (which is standard on those versions) and on >4.0 the OS will animate the rotation for you.

It’s a problem on iOS though. Currently Corona SDK forces “instant rotation” which I could accept if it weren’t for the fact that iOS imposes an animated “empty” black frame when this occurs (and there’s no way to deactivate it). The only acceptable solution is to create an animated rotation of the stage that matches the iOS animated black frame.

I’ve been able to get around this issue with Graphics 1.0, however with Graphics 2.0 I haven’t found a solution.

I’ve played around with this for a while hoping that creating a top level “stage container” would fix this problem. It doesn’t. The reason being that the Origin of the container is fixed and can’t be set. If I create a top level container that auto-rotates properly, all coordinates within the container will be “true Cartesian” (0,0 in the center of the display). While this in theory *would* work, I think there would be many problems trying to implement it.

So, unfortunately it looks like with Graphics 2.0 we are no longer able to have animated autorotation animation that behaves like it should on iOS devices.

Please tell me I’ve missed something…

EDIT:

I understand that you don’t want to make any modifications to the basic functionality of Graphics 2.0, however this whole issue would be solved if you could make a special hardcoded exception for the stage object in that the Origin would be in the top-left, while the Anchor would be in the center.

See response here: http://forums.coronalabs.com/topic/38529-preliminary-results-converting-real-world-app/#entry201661

Anchor points are by definition the origin, so your suggestion for a hardcoded exception would violate the model. Maybe what you are getting is some notion of a camera?

I agree that hardcoding is never a good idea (admittedly, I was a bit frustrated when I wrote that, so I wasn’t thinking clearly)

However your idea about introducing some sort camera does sound interesting…

Just brainstorming here, but I suppose the idea there is that you could move the camera relative to the stage. 

This would include translate, rotate, scale, so then there’s the extra degree of freedom. So in this case, the camera is positioned so that the stage’s origin is at the top-left of the camera’s viewfinder. To rotate about the center of the screen, you just apply a rotation to the camera.

STOP PRESS!!

It’s working! I created a test project and it works as expected on iOS without any additional code needed for autorotation.

I just have a build.settings setup as follows:

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight", "landscapeLeft" } }, iphone = { plist = { UIPrerenderedIcon = true, UIStatusBarHidden = false, UIApplicationExitsOnSuspend = false, UIInterfaceOrientation = "UIInterfaceOrientationLandscapeRight", UISupportedInterfaceOrientations = { "UIInterfaceOrientationLandscapeRight", "UIInterfaceOrientationLandscapeLeft" } } } }

After compiling for and running it on a device, the stage autorotates with animation nicely on iOS.

Graphics 1.0 requires additional code to have animated auto-rotation, but with Graphics 2.0 it looks like your team has already taken care of this. I’ll do some further testing just to make sure everything is working as expected, but preliminary results show that this is a non-issue.

I’ve just confirmed that build 82 doesn’t need any additional proprietary code for an animated auto-rotation of the stage on iOS.

Just specify the desired orientations in build.settings, and Corona takes care of the rest.

See response here: http://forums.coronalabs.com/topic/38529-preliminary-results-converting-real-world-app/#entry201661

Anchor points are by definition the origin, so your suggestion for a hardcoded exception would violate the model. Maybe what you are getting is some notion of a camera?

I agree that hardcoding is never a good idea (admittedly, I was a bit frustrated when I wrote that, so I wasn’t thinking clearly)

However your idea about introducing some sort camera does sound interesting…

Just brainstorming here, but I suppose the idea there is that you could move the camera relative to the stage. 

This would include translate, rotate, scale, so then there’s the extra degree of freedom. So in this case, the camera is positioned so that the stage’s origin is at the top-left of the camera’s viewfinder. To rotate about the center of the screen, you just apply a rotation to the camera.

STOP PRESS!!

It’s working! I created a test project and it works as expected on iOS without any additional code needed for autorotation.

I just have a build.settings setup as follows:

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight", "landscapeLeft" } }, iphone = { plist = { UIPrerenderedIcon = true, UIStatusBarHidden = false, UIApplicationExitsOnSuspend = false, UIInterfaceOrientation = "UIInterfaceOrientationLandscapeRight", UISupportedInterfaceOrientations = { "UIInterfaceOrientationLandscapeRight", "UIInterfaceOrientationLandscapeLeft" } } } }

After compiling for and running it on a device, the stage autorotates with animation nicely on iOS.

Graphics 1.0 requires additional code to have animated auto-rotation, but with Graphics 2.0 it looks like your team has already taken care of this. I’ll do some further testing just to make sure everything is working as expected, but preliminary results show that this is a non-issue.

I’ve just confirmed that build 82 doesn’t need any additional proprietary code for an animated auto-rotation of the stage on iOS.

Just specify the desired orientations in build.settings, and Corona takes care of the rest.

@ingemar: Thanks for posting your build.settings file, it’s nice to know that Graphics 2.0 finally fixes this! However, I’m finishing up a Graphics 1.0 app, and ma having the same issue and concern as you did at the start of the thread. Would you mind sharing how you fixed this for Graphics 1.0?

Thanks!
 

  • David

I think this piece of code might be of help:

http://developer.coronalabs.com/code/proper-orientation-rotation-animation

@ingemar: Thank you, for both posts! :slight_smile:

@ingemar: Thanks for posting your build.settings file, it’s nice to know that Graphics 2.0 finally fixes this! However, I’m finishing up a Graphics 1.0 app, and ma having the same issue and concern as you did at the start of the thread. Would you mind sharing how you fixed this for Graphics 1.0?

Thanks!
 

  • David

I think this piece of code might be of help:

http://developer.coronalabs.com/code/proper-orientation-rotation-animation

@ingemar: Thank you, for both posts! :slight_smile: