How to handle properties in custom classes on cocos builder?

Hi,

I have a simple CCB file that I load. It contains a CCSprite with a custom class and a custom property with a value of 1.

I try to load this from Cocos2d-x but the following assert always interrupt the execution. How can manage this to work?

void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char* pPropertyName, int pInteger, CCBReader * pCCBReader) {

    if(strcmp(pPropertyName, PROPERTY_TAG) == 0) {
        pNode->setTag(pInteger);
    } else {
        ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
    }
}

Thanks.

As far as I know it is not supported yet. I have filed a bug two month ago but there is no fix yet :frowning:

roger solsona wrote:

Hi,
>
I have a simple CCB file that I load. It contains a CCSprite with a custom class and a custom property with a value of 1.
>
I try to load this from Cocos2d-x but the following assert always interrupt the execution. How can manage this to work?
>
>
[…]
>
>
Thanks.

Just to be clear, did you create a loader for the custom class and register it?

E.g.

  ccNodeLoaderLibrary->registerCCNodeLoader("MySprite", MySpriteLoader::loader());

Paras Mendiratta wrote:

As far as I know it is not supported yet. I have filed a bug two month ago but there is no fix yet :frowning:
https://github.com/cocos2d/cocos2d-x/issues/1573

I have just tested the fix to that in last release and it seems to work.

With what version of Cocos2d-x did you make the test?

I am currently using cocos2d-2.1beta3-x-2.1.0 around 1 or 2 months ago. Yes I am using loader to load the custom class. Can you load the custom property (primitive data types) from CCB?

Also waiting to use custom properties on cocos2d-x.

Is there any new how to do it or if it is supported?

Paras Mendiratta wrote:

With what version of Cocos2d-x did you make the test?
>
I am currently using cocos2d-2.1beta3-x-2.1.0 around 1 or 2 months ago. Yes I am using loader to load the custom class. Can you load the custom property (primitive data types) from CCB?

Paras Mendiratta wrote:

With what version of Cocos2d-x did you make the test?
>
I am currently using cocos2d-2.1beta3-x-2.1.0 around 1 or 2 months ago. Yes I am using loader to load the custom class. Can you load the custom property (primitive data types) from CCB?

cocos2d-2.1beta3-x-2.1.1, the latest release. And yes, it works as described by James Chen (dumganhar) on the issue page: https://github.com/cocos2d/cocos2d-x/issues/1573 (look at 3rd last post)

Andargor theWise wrote:

Paras Mendiratta wrote:
> With what version of Cocos2d-x did you make the test?
>
> I am currently using cocos2d-2.1beta3-x-2.1.0 around 1 or 2 months ago. Yes I am using loader to load the custom class. Can you load the custom property (primitive data types) from CCB?
>
cocos2d-2.1beta3-x-2.1.1, the latest release. And yes, it works as described by James Chen (dumganhar) on the issue page: https://github.com/cocos2d/cocos2d-x/issues/1573 (look at 3rd last post)

Finally, I found how to do it and it works on Cocos2d-x 2.0.4.

It is just:

void SPLabelLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, cocos2d::extension::CCBReader * pCCBReader)
{
if(pPropertyName->compare(“customPropertyName”) == 0)
{
// Do something
}
else
{
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
}
}

@rogersolsona You assert is fire because you didn’t define a case for specific custom property. It has to be the same you added on cocosbuilder.