Landscape in iPhone

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Metalero
Posts: 14
Joined: Tue Sep 07, 2010 4:02 pm

Landscape in iPhone

Post by Metalero »

After hours searching... I gave up, and ask for som help

I need to make the game I'm developing for thi iPhone to run only in Landscape orientation

I tryied adding de UIInterfaceOtientation vaule in the info.plist and adding a viewcontroler (as many tutorial say) but with this... I get an error (something like "error when trying to install application'")

Then I tryied to modify in any way the projection matrix (driver->setTransoform), getting the current matrix and setting its rotation to (0,0,90), and setting this new matrix to the driver transfomation... but it had no effect (I don't know very much about matrix manipulation)

So finally I decide to rotate the camera (and change a lot of things), but before doing all this, I preffer ask if anybody knows a good way to do it.

So I somebody can give any hint of how can I do this i would be gratefull
zet.dp.ua
Posts: 66
Joined: Sat Jul 07, 2007 8:10 am

Post by zet.dp.ua »

Just force landscape orientation of your main view controller

Code: Select all

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Metalero
Posts: 14
Joined: Tue Sep 07, 2010 4:02 pm

Post by Metalero »

That's the problem, I've not ViewController coz' I'm using the template posted here: http://irrlicht.sourceforge.net/phpBB2/ ... e&start=75

Wich hasn't any one, but it use an OGL-ES View
Arcoroc
Posts: 51
Joined: Wed Oct 01, 2008 11:40 pm
Location: Canada

Post by Arcoroc »

Metalero wrote:That's the problem, I've not ViewController coz' I'm using the template posted here: http://irrlicht.sourceforge.net/phpBB2/ ... e&start=75

Wich hasn't any one, but it use an OGL-ES View
You could try something like this in your application delegate class, calling the method during your init flow:

Code: Select all


-(void)setLandscapeMode
{
	UIApplication* application = [UIApplication sharedApplication] ;
	
	if ( application.statusBarOrientation == UIInterfaceOrientationPortrait )
	{
		// set landscape mode
		application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft; 
		window.hidden = false ;
		
		window.bounds = CGRectMake(0.0, 0.0, window.bounds.size.height, window.bounds.size.width);	// change orientation
		CGAffineTransform landscapeTransform = CGAffineTransformConcat( CGAffineTransformIdentity, CGAffineTransformMakeRotation (M_PI / -2) );
		window.transform = landscapeTransform ;
				
	}
	
}
L/
Post Reply