Menu ignores setAnchorPoint

I’m using 3.2. I’m trying to position my menu in the top left corner, this is my code:

// create menu with options array
    cocos2d::Menu* menu = cocos2d::Menu::createWithArray(menuItems);
    menu->alignItemsVertically();
    menu->setAnchorPoint(Vec2(0,1));
    menu->setPosition(Vec2(origin.x + 0, origin.y + visibleSize.height));
    this->addChild(menu, 1);

No matter what I set the anchor point to, the menu always shows up in the same place, and the top and left half of it is off the sceen. The anchor point seems to be stuck at (0.5,0.5). What am I missing?

Nobody knows?

What I’m trying to achieve is to left align the menu and move it to the top left, but I can’t figure out the behaviour of the menu object.

I thought I’d just do it by positioning it based on the menu’s height (collecting the height of every menu item), but my menus still align differently based on the number of items, it’s like the positioning changes depending on the number of items, and isn’t actually centered.

All my MenuItemLabel items have anchors set to (0,0.5). I have two different menus (on two diff scenes), one has 2 items, the other 5 items. Both menus are positioned like this:

menu->setPosition(Vec2(origin.x + 0, origin.y + visibleSize.height - heightAllItems/2));

For some reason, the menu with 5 items is positioned about half a label height higher than the menu with 2 items (which is actually flush with the top left of the screen). If I add three menu items to the menu that has 2, it gets bumped up and part of it goes off screen too. I don’t understand what’s happening. :frowning:

Yes, I’d love to know the answer to this one as well; seems like a straight forward question. Even though this is an old post - it still persists in version 3.10. Might have to settle for calculating it yourself based off of getContentSize() in the mean time.

Also occurs on 3.16 :confused:
It does get ignored altogether.

Edit 2: I’m trying to get into the code and see if I can find the issue. I see that the anchor function works well and the menu does receive the new anchor value. can anyone point to where nodes are being drawn?