I made some ui with CocoStudio 1.1.0.0.
and load it into Scene.
when i set uiButtonInstance->setEnable(false),
it disappear on screen, instead of showing disable state.
I found comment of UIWidget.setEnabled on cpp source says…
“true if the widget is enabled, widget may be touched and visible, false if the widget is disabled, widget cannot be touched and hidden.”
I can not find a method to disable of uibutton, if i call method setEnabled for uibutton then it is invisible and I can not see it on screen.
so, how can i set disable state for uibutton?
i use cocos2dx-2.2.3 and coco studio 1.2.0.1
@dungmv
You have good English! but this:-
I can not foundfind a method to disable of uibutton, if i call method setEnabled for uibutton then it is invisible and I can not see it inon screen.
so, how can iI set disable state for uibutton?
Your English is much,much better than my grasp of your language.
I only want to help you improve.
There’s no disable(), it’s setEnabled(boolean).setBright(boolean)just changes the visual sprite basically.setEnabledcalledsetBright` anyway, so you don’t need to double up on that’.
I’ve got a related question, is it possible to disable a button but still have it swallow touches, as in if you disable a button, have the touch not touch the thing thats behind it? button->setSwallowTouches(true) doesn’t seem to do it, neither does button->setTouchEnabled(true) nor did button->setPropagateTouchEvents(false).
Looking at the source, Widget::onTouchBegan returns false before checking anything other than isVisible or isEnabled, so maybe I can’t without subclassing.
I have used setBright(false) when showing the disabled state of the Button. Basically button activates power-up and I need to add logic such that button remains disabled while power-up is on cooldown.
But there is a weird issue. When setBright(false) is called for first time, the button disappears from HUD . After cooldown gets over, button becomes visible again. Now if I activate the power-up, then setBright(false) works as intended and button becomes greyed and not invisible.