Issue when loading CCControlButton from ccbi


Hi there,

I’m just taking a look at the new CocosBuilder loading stuff, and generally it’s pretty awesome. However, I’ve found a small problem: when loading a ccbi with a CCControlButton inside it, Cocos2d-x crashes with an “Unexpected property: backgroundSpriteFrame|4” error. This can be mitigated by loading up the ccb before publishing and changing the “backgroundSpriteFrame|4” and “titleColor|4” properties from 4 to 3, but the CocosBuilder app seems intend on saving them non-sequentially all the time. It’s kind of annoying having to change all the properties manually every time you want to republish. :slight_smile:

Does anybody know why CocosBuilder is so keen to leave out number 3 in it’s sprite frame list? And shouldn’t Cocos2d-x cope with this weirdness regardless?

Thanks for your help.



What’s the version of CocosBuilder you use? Maybe you should try a version on github(
Just let me know whether it works? :slight_smile:


Hi James,

Yep that was my first thought too, but unfortunately this behaviour still takes place when I compile the latest version from Github.

Thanks for your help,



I get same problem.


It seems to be a bug in cocos-2dx. If you look at CCControl.h (from CocosBuilder), you have the following block inside:

/** The possible state for a control.  */
    CCControlStateNormal       = 1 << 0, // The normal, or default state of a control—that is, enabled but neither selected nor highlighted.
    CCControlStateHighlighted  = 1 << 1, // Highlighted state of a control. A control enters this state when a touch down, drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
    CCControlStateDisabled     = 1 << 2, // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
    CCControlStateSelected     = 1 << 3  // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.

And when you have a look at CCControlButtonLoader.cpp in cocos2d-x, you have this:

#define PROPERTY_TITLE_NORMAL "title|1"
#define PROPERTY_LABELANCHORPOINT "labelAnchorPoint"
#define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder!

1 << 2 equals 4, not 3, here is where the bug is lying



Well spotted Bertrand. Changing the values in CCControlButtonLoader.cpp fixes the problem. Thanks very much for your help.



Hi guys, thanks for your job. I committed for this bug.
So the problem is that:
# The current test suite didn’t cover DISABLED state of CCControlButton
# CocosBuilder v2.0 always generate “4” for CCControlButton::DISABLED state, while the ccb & ccbi file in test suite is manually modified to “3”

Issue #1409 created.