Not sure why the menu is aligned to Top Left corner , previous version the menu was aligned perfectly to the center. Testing in iPhone 4.
I know the solution [menu setPosition:ccp( size.width/2, size.height/2)]; but wanted to understand why its Aligned to Top Left.
To get the same result please try this in AppDelegate
[director_ pushScene: [HelloWorldLayer scene]];
instead of
[director_ pushScene: [IntroLayer scene]];
My Result and my Code

UPDATED SOURCE
MenuLayer.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface MenuLayer : CCLayer {
}
+(CCScene *) scene;
@end
MenuLayer.m
#import "MenuLayer.h"
@implementation MenuLayer
+(CCScene *) scene
{
CCScene *scene = [CCScene node];
MenuLayer *layer = [MenuLayer node];
[scene addChild: layer];
return scene;
}
-(id) init
{
if( (self=[super init]) ) {
CCMenuItem *itemAchievement = [CCMenuItemFont itemWithString:@"Play" block:^(id sender) {}];
CCMenuItem *itemLeaderboard = [CCMenuItemFont itemWithString:@"Settings" block:^(id sender) {}];
CCMenu *menu = [CCMenu menuWithItems:itemAchievement, itemLeaderboard, nil];
[menu alignItemsVertically];
[self addChild:menu];
}
return self;
}
@end
AppDelegate.m
[director_ pushScene: [MenuLayer scene]];
OK, I’ll tell you the answer first:
You have something gone wrong 🙂 .. You must have changed the position of the parent, or its grandparent, … etc.
EDIT:
Your error is running
CCDirectorinside this method:Instead, you must run the
CCDirectorlike so:Evidence:
Read the cocos2d docs! They say that if you are running on iOS versions prior to iOS 6, you mustn’t run the
CCDirectorinside theapplication: didFinishLaunching:method.From the docs:
Here is your pic, dissected:
That’s a total mess… There is no way cocos2d default behavior is like that. Create a new cocos2d v2.x, and clean up
HelloWorldLayer.m, and here is the result: