After a few days of completion, I finally moved the existing project from cocos2dx 2.2.2 to cocos2dx 3.2, and almost gave up 3.2. But at the last moment, I completed the completion.
Cocos2dx 2. x to 3. X is a huge change, which can be regarded as completely different. The previous class names start with CC and are all removed. Many Enum use Enum class.
So, you know 2.x, sorry, you are more difficult than learning 3. X. If you use the 2.x method in 3.x, it will be all pitfall...
Let's get down to the truth,
2. x is invisible when the button is set to disabled. 3. X is not disabled, but does not respond to the touch event.
When editing the cocostudio UI, the buttons are in three States (there are three images in different States), but there is no function to change the State accordingly.
Therefore, the source code is analyzed and it is found that it is an image in onpressstatechangedtodisabled (); the image is changed to disabled. Find another
In the UI of its base class: setbright and sethighlight of the widget call this onpressstatechangedtodisabled, but setenabled is only changed to a member change,
Therefore, if you set disabled here, it will not have any effect. In addition to the above two functions, there is also a function setbrightstyle to set whether the button is normal or highlighted
The following is the definition of brightstyle.
Enum class brightstyle
{
None =-1,
Normal,
Highlight
};
The following is a function for disabling and enabling packaging.
// Set the button to disable the Enable status
Inline void setbuttonenabled (ui: button * parambutton, bool paramenabled)
{
If (isnull (parambutton) return;
If (paramenabled)
{
Parambutton-> setbright (true );
Parambutton-> setenabled (true );
Parambutton-> settouchenabled (true );
}
Else
{
Parambutton-> setbright (false );
Parambutton-> setenabled (false );
Parambutton-> settouchenabled (false );
}
}
[Cocos2dx note 015] three states of cocos2dx buttons