Game Development Community

iT2D 1.4.1 Orientation change happens at incorrect angles - RESOLVED

by Conor O'Kane · in iTorque 2D · 03/25/2011 (5:36 am) · 10 replies

Build: 1.4.1

Platform: iPad

Target: On Device - landscape mode

Issues: I was very happy to see that orientation changing now works on the iPad. However it's not quite working properly. Firstly, portrait orientations are not handled - that code is just commented out in iPhoneMain.mm.
Secondly, orientation changes are happening at incorrect angles.

When holding the iPad with the home button on the left, and the tablet tilted towards the viewer at about 45 degrees, start tilting it away from you (towards horizontal). The first orientation change occurs at about 30 degrees (the screen flips upside-down). Continue tilting and at about 10 degrees the screen flips back to normal. Then at about 5 degrees the screen flips upside-down again.

Obviously the screen should flip only once, when the device crosses around -10 degrees and not flip back until it passes +10 degrees to prevent flickering when laid on a flat surface.

#1
03/25/2011 (7:28 am)
Excellent information Conor. Logged as ITGB-141.
#2
03/25/2011 (7:29 am)
Quote:Firstly, portrait orientations are not handled - that code is just commented out in iPhoneMain.mm.

I don't have the code in front of me (not technically supposed to be working today). Do you mean it can run in portrait, but does not flip when tilting far enough?
#3
03/25/2011 (7:41 am)
Mich - here's the function straight out of iPhoneMain.mm
//Luma: Store current orientation for easy access
void _iPhoneGameChangeOrientation(S32 newOrientation)
{
	_iPhoneGameSetCurrentOrientation(newOrientation);
	Con::executef( 2, "oniPhoneChangeOrientation", Con::getIntArg(newOrientation) );
	
//Sven: adding landscape auto rotation support, 
#ifdef TORQUE_ALLOW_AUTOROTATE
	
	if(Con::getIntVariable("$pref::iDevice::ScreenOrientation") != 1)
	{
	
		//Start "collecting animations"
		[UIView beginAnimations: nil context: nil];
			
		switch(newOrientation)
		{
			case iPhoneOrientationLandscapeLeft:
				platState.Window.transform = CGAffineTransformMakeRotation(mDegToRad(0.0f));
			break;
				
			case iPhoneOrientationLandscapeRight:
				platState.Window.transform = CGAffineTransformMakeRotation(mDegToRad(180.0f));	
			break;
			
				//Sventodo: This is for reference. You can also resize the view dynamically with
				//no stretching, etc. 
			/*case iPhoneOrientationPortrait:
				platState.Window.transform = CGAffineTransformMakeRotation(mDegToRad(270.0f));
			break;
				
			case iPhoneOrientationPortraitUpsideDown:
				platState.Window.transform = CGAffineTransformMakeRotation(mDegToRad(90.0f));	
			break;*/
			default:
				break;
		}
	
		//Show them
		[UIView commitAnimations];
		
	}
	else {
		//Only handling landscape orientation rotations. The other makes no sense by default.
	}

#endif //TORQUE_ALLOW_AUTOROTATE

}

Looks like Sven decided not to implement portrait mode flipping, because it made no sense on the iPhone. I'm not sure if it makes any sense on the iPad either, but it would be a shame if Apple rejected an app because it didn't support both portrait orientations on iPad.
#4
03/25/2011 (8:07 am)
Apple originally stated all orientations had to be supported, but the backlash was obscene. They modified it to a recommendation to support both variants of your preferred orientation, and not a hard requirement. It should be in the latest guidelines.

Supporting all 4 really only works for certain apps, of course. Some clever stock and calculator apps give some different views in landscape, like the original calculator app on iPhone does. But if your game is an omni-directional 4-player game with text oriented along all edges - yeah, don't care about adjusting :)
#5
06/02/2011 (9:44 am)
Any ETA on this bug, or is it even high on the priority list? This is currently the only engine bug (I think) that I need fixed before I can release my game.
#6
06/02/2011 (9:50 am)
@Conor - My current task deals with resolution handling, so there is a good chance I will be diving into the orientation code to make sure it supports my modifications. I don't have an ETA, but it is in the crosshairs.
#7
06/02/2011 (10:10 am)
Thanks for the quick update Mich - much appreciated!
#8
07/04/2011 (12:01 pm)
So I need to clarify this bug please.

Does this mean that currently the game will be unable to respond to orientation changes, from landscape to portrait, each 90 degrees?

Considering the entire basis of my gameplay depends on this, I need to know if this isn't going to work so I can start learning what I need to do to fix it.
#9
07/04/2011 (8:46 pm)
John - I haven't tested portrait orientation changes carefully, but what you can expect is that as the iPad approaches horizontal you will get unexpected orientation changes. With the iPad held close to vertical I found that the orientation stayed the right way round, however when I do a full 180 rotation (to the other landscape orientation) the screen flips 2 or 3 times before settling on the correct layout.
#10
09/27/2011 (7:26 pm)
Fixed in 1.5.