How to show disable state of UIButton?

auto Level_item_DEL3 = MenuItemImage::create("LEVEL 3.png", "LEVEL 3.png", "LEVEL 3 D",CC_CALLBACK_1(LevelScene::DEL3B, this));

Thatā€™s a MenuItemImage, not a ui::Button. Thereā€™s a whole ui::Widget library within cocos that handles all that kind of stuff better IMO.

Assuming that "LEVEL 3 D" is a PNG with a disabled texture on it, how are you enabling/disabling the MenuItemImage? If itā€™s being added to a MenuItem or something, maybe the parent item is controlling its state?

So far it isnā€™t. itā€™s always enabled and i want it to start of as disabled (Iā€™ll sort out the whole behavior tree).

this is what Iā€™m asking :slight_smile:

Did Level_item_DEL3 ->setEnabled(false); not work? https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/2d/CCMenuItem.h looks like it should, since it inherits from MenuItemSprite.

1 Like

I can assure you it did not work. The button IS DISABLED but the image is the same, and not ā€œLEVEL 3 Dā€

LEVEL 3D.png?

firstly check if your image is a pngā€¦ secondly why doesnā€™t it have extension. then add it with full extension.

1 Like

It was always a PNG.

What do you mean?

last file without .png extension

2 Likes

oh my deary me! Thanks! nice catch