iOS 6 screen rotation, Game Center crash, and more

Dec 6, 2012 at 9:37 PM

I just uploaded a new patch, 13402.

This fixes a critical bug in ExEn that causes the game to crash if Game Center is opened in a Landscape oriented game on an iPhone running iOS 6 or later. (The iPad is unaffected.)

IMPORTANT: If you want to enable Game Center for your game, you *must* now enable Portrait orientation for the iPhone in your application's .plist properties file, even if your game is Landscape only. (In MonoDevelop: Right-click the game project, choose Options, and go to Build > iPhone Application in the left menu and make sure iPhone Portrait is enabled.) The screen orientation will be appropriately locked to Portrait or Landscape in code now instead. This solution is not exclusive to ExEn — iOS developers across the board have had to use a similar solution (e.g., cocos2d).

NOTE: Beyond the Game Center fix, this patch also supersedes the old patch that I uploaded for ExEn iOS 6 screen rotation problems (patch ID 12935). That old code wasn't quite correct. I've learned a lot more about iOS screen rotation in the meantime, and I think I have fixed screen rotation in ExEn for both iOS 5 and 6 once and for all. Apple changed things considerably between the two versions of iOS, but this should handle all cases now.

The key changes are in these files:

- ExEnEmTouch/ExEnEmTouchGameView.cs
- ExEnEmTouch/Game/GraphicsDeviceManager.cs

Additionally, if you are creating a Landscape mode game and would like to control exactly how your app is rotated when it initially loads, there is another file included in this patch that will help:

- EnEnEmTouch/Game/Game.cs

You can uncomment line 27 in Game.cs and change the UIInterfaceOrientation value to set your app's starting rotation however you want. I apologize it's not more automatic; I couldn't find a better way to integrate this.