Change Cocos2D template to portrait

The template that comes with Cocos2D 0.99.5 is set in landscape mode. Sometimes you want portrait though, so I did the following and it seems to work, and reorient without fail.

In GameConfig.m


// REPLACE THIS LINE #define GAME_AUTOROTATION kGameAutorotationNone
// WITH THE FOLLOWING
#define GAME_AUTOROTATION kGameAutorotationUIViewController

In RootviewController.m in the section of

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController

// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations

// REPLACE THIS LINE return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
// WITH THE FOLLOWING
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );

In your appdelegate.m class file


[director setAnimationInterval:1.0/60];
[director setDisplayFPS:YES];
// ADD THE FOLLOWING LINE HERE
[director setDeviceOrientation:kCCDeviceOrientationPortrait];