ioscocos2d-iphoneios7ccmenu

CCMenu misplaced under iOS 7


Under iOS 6 all my CCMenus appeared centered on the screen by default, if I did not assign an explicit position. Under iOS 7 the menus are positioned off screen.

Do I have to assign an explicit position under iOS 7?

iOS 6:

enter image description here

iOS 7:

enter image description here


Solution

  • Basically there are two underlying problems.

    1. If you have hidden your status bar under iOS 6, this will not work for iOS 7 without adding an additional value to your Info.plist (View controller-based status bar appearance -> NO)

    2. Due to a bug in Cocos2D your screen size will be calculated wrong, if your status bar is visible.

    You have to different options to solve this problem:

    1. Set a CCMenu position explicitly instead of using the implicit positioning (e.g: menu.position = ccp(self.contentSize.width/2, self.contentSize.height/2);)
    2. Set View controller-based status bar appearance -> NO in your Info.plist if you don't want to show the status bar anyway