Search code examples
cocos2d-x

CCMenuItemFont adds stroke


CCLabelTTF has property enableStroke.

Just wonder if CCMenuItemFont can support stroke enable?

or is there any method to create similar result

your comment welcome


Solution

  • MenuItemFont creates a menu item with given string and uses label just to display the text, nothing more. You need MenuItemLabel to create a menu item with custom label like this:

    auto textLabel = LabelTTF::create("Hello World", "Arial", 22);
    // XXX: Additional settings here
    
    auto menuItem = MenuItemLabel::create(textLabel, CC_CALLBACK_1(GameScene::onMenuItemClicked, this));
    menuItem->setPosition(Point(200, 100));
    
    auto menu = Menu::create(menuItem, NULL);
    menu->setPosition(Point::ZERO);
    addChild(menu);