How to highlight button?
i have done with button_name->setFocused(true);
using this only first time work fine after button doesn’t highlight
Instead of button I often use :
Vector<MenuItem*> menuItems;
auto buttonSize = Size(background->getContentSize().width*0.8, background->getContentSize().height*0.13);
auto stillColor = Color3B(120, 200, 100);
auto clickedColor = Color3B(20, 50, 0);
auto btt1Still = Sprite::createWithTexture(background->getTexture());
btt1Still->setContentSize(buttonSize);
btt1Still->setColor(stillColor);
auto btt1Clicked = Sprite::createWithTexture(background->getTexture());
btt1Clicked->setContentSize(buttonSize);
btt1Clicked->setColor(clickedColor);
auto btt1 = MenuItemSprite::create(btt1Still, btt1Clicked, CC_CALLBACK_0(MainMenu::btt1Touched, this));
auto btt1Label = Label::createWithTTF("Join Local Game", "markf.ttf", 20);
btt1Label->setPosition(buttonSize.width/2, buttonSize.height/2);
btt1->addChild(btt1Label);
menuItems.pushBack(btt1);
auto buttonHolder = Menu::createWithArray(menuItems);
buttonHolder->alignItemsVerticallyWithPadding(10);
buttonHolder->setPosition(background->getPosition());
this->addChild(buttonHolder);
inside a class that’s extends Scene, with that if you save a pointer to the (in this case) btt1Still variable by changing it’s color / texture you can make the appearance of the button being clicked.
Anyway
the simplest way, if the code you used doesn’t work, is to have a transparent sprite with the highlighted button omg over the button and whenever you want to highlight it jut change the transparency of the sprite.
I guess you are doing that to something like a tutorial isn’t it?
I believe it’s just setHighlighted(true)
instead of focused?
However, you didn’t really describe how it should behave or the scenario you are working toward.