Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Say I have a game that runs full-screen on iPhone 4S and older devices. The balance of the game is just right for the 480 x 320 screen and associated aspect ratio. Now I want to update my game to run full-screen on the new iPhone/iPod Touch where the aspect ratio of the screen is different.

It seems like this can be challenging for some games in terms of maintaining the "balance". For example if the extra screen space was just tacked onto the right side of Jet Pack Joyride the balance would be thrown off since the user now has more time to see and react to obstacles.

Also it could be challenging in terms of code maintenance. Perhaps Jet Pack Joyride would slightly increase the speed of approaching obstacles when the game is played on newer devices. However this quickly becomes messy when extra conditional statements are added all over the code. One solution is to have some parameters that are set in once place at start-up depending on the device type.

What are some strategies for updating iOS games to run on the new iPhone and iPod Touch?

Edit - more info: I wonder what happens with a game like Plants vs Zombies? There's quite a bit of artwork that's probably sized to the 320x480 screen. Perhaps the lawn background's width can be increased while the size of the zombies and the row heights stay the same.

share|improve this question
4  
Technically, this is the same problem with supporting both the iPad (4:3) and the legacy smaller devices (3:2). Or all PC games. Personally I say just make it fun for the "hardest" platform and just let the player see more. –  Tetrad Sep 24 '12 at 12:42
1  
...are you actually making a game that runs full-screen on iPhone 4S and older devices, and which you are now updating to iPhone5? Or is this an “I would like to participate in a discussion about...” question? –  Trevor Powell Sep 25 '12 at 3:05
    
@TrevorPowell Yes I've created and delivered a game to a client that runs full-screen on 4S and older iPhone and iPod Touch devices. Now the client would like the game to be updated to run full-screen on iPhone 5 and 5th gen iPod Touch. –  SundayMonday Sep 26 '12 at 15:39

1 Answer 1

up vote 2 down vote accepted

I found the solution for this from the Cocos2d-x forums. The following code is needed in the didFinishLaunching method:

  // Set RootViewController to window
  NSString *reqSysVer = @"6.0";
  NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
  if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) {
    [window setRootViewController:viewController]; //iOS 6
  } else {
    [window addSubview: viewController.view]; //iOS 5 or less
  } 

An example of the full method:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
  // Override point for customization after application launch.
  // Add the view controller's view to the window and display.
  window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
  EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
                                 pixelFormat: kEAGLColorFormatRGBA8
                                 depthFormat: GL_DEPTH_COMPONENT16
                          preserveBackbuffer: NO
                                  sharegroup: nil
                               multiSampling: NO
                             numberOfSamples: 0 ];
  // Use RootViewController manage EAGLView
  viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
  viewController.wantsFullScreenLayout = YES;
  viewController.view = __glView;
  // Set RootViewController to window
  NSString *reqSysVer = @"6.0";
  NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
  if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) {
    [window setRootViewController:viewController]; //iOS 6
  } else {
    [window addSubview: viewController.view]; //iOS 5 or less
  }
    [window makeKeyAndVisible];
    __glView.multipleTouchEnabled = YES;
    [[UIApplication sharedApplication] setStatusBarHidden: YES];
    cocos2d::CCApplication::sharedApplication()->run();
    return YES;
}

and possibly this code in your RootViewController:

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate {
    return YES;
}
share|improve this answer
    
You should probably also note what this code actually does for people just reading at a glance. –  electroflame Sep 26 '12 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.