Game Development Community

IPAD Landascape Screen Orientation

by Edoardo · in iTorque 2D · 11/19/2010 (11:21 am) · 10 replies

I have serious problems with the autoscreen orientation (the game is only in Landscape mode)

Anyone had resolved this issue?

#1
11/19/2010 (1:03 pm)
We gave up trying to fix it and "locked" it into one orientation only.
#2
11/19/2010 (8:12 pm)
Doesn't the Apple documentation say that the iPad version have to at least be able to rotate 180 degrees? So if you are in horizontal mode, it should be able to rotate to horizontal upside down.
#3
11/19/2010 (9:00 pm)
Justin, I think you are right ... we were relying on this clause:

If your application interprets changes in device orientation as user input, you can handle rotation in application-specific ways. For example, if your application is a game that allows people to move game pieces by rotating the device, you can’t respond to device rotation by rotating the screen. In a case like this, you should launch in either variant of your required orientation and allow people to switch between the variants until they start the main task of the application. Then, as soon as people begin the main task, you can begin responding to device movement

But it does infer that we have to support at least the two landscape orientations until the game starts :(
#4
11/19/2010 (9:28 pm)
There was a post on Unity's forums awhile back where an app was rejected for because the Unity splash screen didn't rotate - it doesn't look good if Apple is picky about even a splash screen.

Since it looks like the iPad version of War Evolved will need to rotate, I just started to work on rotating iTGB. I think I figured most of it out, I am now able to rotate the game after it starts up. I'm still working on getting the splash screen to be oriented correctly but I expect to be able to tonight. I'll post the code as soon as it is completely working.
#5
11/19/2010 (9:55 pm)
We've had the rotating working, including the splash, but the rotating was causing problems as both games use tilt.
#6
11/20/2010 (1:13 am)
So the accelerometer is off? Couldn't you just multiply the horizontal value by -1 if the orientation is upside down?

In either case, I got the orientation working including the splash screen for War Evolved. Since it doesn't require specific accelerometer values I don't need to make sure they are accurate according to the orientation.

How did you get rotation working? I created a new view controller and adding iPhoneOGLVideo *glVideo to it. Then in the new view controller all I had to do was return the correct values for shouldAutorotateToInterfaceOrientation. Finally I removed all of the orientation code in iPhoneWindow.mm (such as the function setScreenOrientation) since that was messing up the splash screen.
#7
11/20/2010 (7:22 am)
YES Apple reject all application on iPad that don't rotate in the same mode (example landascapeleft/landascaperoght or protrait/protraitupsidedown)

The solution is to wrap iTGB with a UIViewController but i've not experience with Object-C.

Justin can you post your view controller code?

Thanks
#8
11/24/2010 (2:40 am)
Sure, I added the following to the end of iPhoneOGLVideo.h:
@interface iPhoneOGLVideoController : UIViewController {
	
}

@end

And then this goes in at the end of iPhoneOGLVideo.mm:
@implementation iPhoneOGLVideoController

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}


@end
This is for landscape mode.

In order for this to actually work, you have to create a new iPhoneOGLVideoController and add the iPhoneOGLVideo view to it. In iPhoneWindow.mm you'll notice the view being created with iPhoneOGLVideo *glView;. I've changed my iPhoneWindow.mm around a lot so I can't give you specific line numbers, but instead of initializing the view right away do the following:

glViewController = [[iPhoneOGLVideoController alloc] init];
	glView = [[iPhoneOGLVideo alloc] initWithFrame: rect];	
	glViewController.view = glView;

That's it, now the screen will rotate. I forgot everything that I took out, but I completely stripped iPhoneWindow.mm of any custom view orientations since I am letting the iPhone/iPad handle it. For example, as I said above, I completely deleted the setScreenOrientation function. Let me know if you are having a specific problem, I'm sorry I can't give you specific steps in what to remove.
#9
12/01/2010 (6:46 pm)
Guys, just a heads up, both iPad apps were approved by Apple without any support for orientation other than a default landscape, home button on right.

Don't forget though that your mileage may vary.
#10
12/01/2010 (7:20 pm)
Thanks for the update, Scott, and let us know when you make them live.