Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:32:09+00:00 2026-06-11T11:32:09+00:00

Not sure why the menu is aligned to Top Left corner , previous version

  • 0

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

enter image description here

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]];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:32:10+00:00Added an answer on June 11, 2026 at 11:32 am

    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 CCDirector inside this method:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        ...
        // Remove this code ! 
        [director_ runWithScene:blah];
    } 
    

    Instead, you must run the CCDirector like so:

    // This method is part of the CCDirectorDelegate methods
    // Add it below the - (BOOL)application: didFinishLaunchingWithOptions:
    -(void) directorDidReshapeProjection:(CCDirector*)director
    {
        if(director.runningScene == nil) {
            // Add the first scene to the stack. The director will draw it immediately into the framebuffer. (Animation is started automatically when the view is displayed.)
            // and add the scene to the stack. The director will run it when it automatically when the view is displayed.
            [director_ runWithScene: [HelloWorldLayer scene]];
        }
    }
    

    Evidence:

    Read the cocos2d docs! They say that if you are running on iOS versions prior to iOS 6, you mustn’t run the CCDirector inside the application: didFinishLaunching: method.

    From the docs:

    This is needed for iOS4 and iOS5 in order to ensure
    that the 1st scene has the correct dimensions
    This is not needed on iOS6 and could be added to the application:didFinish…

    Here is your pic, dissected:

    enter image description here

    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:

    // Achievement Menu Item using blocks
    CCMenuItem *itemAchievement = [CCMenuItemFont itemWithString:@"Achievements" block:^(id sender) {}];
    // Leaderboard Menu Item using blocks
    CCMenuItem *itemLeaderboard = [CCMenuItemFont itemWithString:@"Leaderboard" block:^(id sender) {}];
    
    CCMenu *menu = [CCMenu menuWithItems:itemAchievement, itemLeaderboard, nil];
    
    [menu alignItemsVertically];
    
    [self addChild:menu];
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty sure i've seen this somewhere (not counting the help menu), and I
The following code is an example from the NCURSES menu library. I'm not sure
I'm trying to achieve a Drag and Drop menu affect. I'm not sure how
Menu does not display in line. Not sure how to call the CSS code.
I'm creating a searchable version of my university's course listings, and am not sure
Not sure if it's a best practice, but we wish to have a menu
I'm not sure which container or component can help to create the following menu
Not sure whats going on here, or what could be the integer in this
Not sure if im just being stupid or something but here goes i work
Not sure how to ask this, but i'll give it a try: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.