Cocos2d-x cocostudio UIButton control setEnabled (false) method failure Solution
1. The UIbutton button has three statuses: Normal, pressed, and disabled, when we set our three state images in the Cocostudio Editor, when we use the setEnabled (false); Method in our project, we find that UIbutton disappears, the solution is as follows:
① Enter UIwidget. cpp
Find the visit (); method. here we need to modify the visit (); method to remove the if judgment.
The result is as follows:
Void Widget: visit ()
{
CCNode: visit ();
}
② ModifyWidget: setEnable ()Method, you only need to add a line of code, as shown below
Void Widget: setEnabled (bool enabled)
{
_ Enabled = enabled;
If (_ widgetChildren & _ widgetChildren-> count ()> 0)
{
CCObject * child;
CCARRAY_FOREACH (_ widgetChildren, child)
{
(Widget *) child)-> setEnabled (enabled );
}
}
SetBright (enabled); // Add this row
}