How to resize a Button; Things I didn’t know about Cocos2d-x, but I probably could have read in the docs somewhere #6

You can only resize the Buttons around the size of its text using the content size of the inner Label, which is called the _titleRenderer. Here’s a working lambda you can shove into your game. I suggest enabling Scale9.

    auto resize_btn = [](ui::Button* button) {
        auto lbl_size = button->getTitleRenderer()->getContentSize();

                lbl_size.width * 1.1f,
                lbl_size.height * 1.1f

Leave a Reply

Your email address will not be published.