CocosBuilder icon indicating copy to clipboard operation
CocosBuilder copied to clipboard

Overriding of custom properties not working

Open sarah-j-smith opened this issue 11 years ago • 11 comments

If a file A.ccb includes a sub-ccb file B.ccb, where the base node of B.ccb is a custom class (non-JS, eg. Obj-C class) with a property then only the values of the properties declared in B.ccb appear once A.ccb is loaded. Any over-riding of the property values when you create instances of B in A are thrown away, even tho' the UI allows you to enter values there.

I'm seeing this in CocosBuilder 3.0alpha3.

Someone reported this on the forums and provided a test case:

http://www.cocos2d-iphone.org/forum/topic/148182#post-298459

In other words if I have B.ccb define a chair with property dollarValue which is an Int, I cannot in A.ccb have two chairs with different dollar values. Even tho' the UI seems to imply that this should work.

Also this code:

// Forward properties for sub ccb files
if ([node isKindOfClass:[CCBFile class]])
{
    CCBFile* ccbNode = (CCBFile*) node;
    if (ccbNode.ccbFile && isExtraProp)
    {
        node = ccbNode.ccbFile;

        // Skip properties that doesn't have a value to override
        NSSet* extraPropsNames = node.userObject;
        setProp &= [extraPropsNames containsObject:name];
    }
}

Seems to imply that overrides should work.

In my game I have a reachableFrom property - when I put values in there in the calling CCB file they are ignored:

ccb-bug

This code in CCBReader.m seems to remove the "instance" node:

// Handle sub ccb files (remove middle node)
if ([node isKindOfClass:[CCBFile class]])
{
    CCBFile* ccbFileNode = (CCBFile*)node;

    CCNode* embeddedNode = ccbFileNode.ccbFile;
    embeddedNode.position = ccbFileNode.position;
    //embeddedNode.anchorPoint = ccbFileNode.anchorPoint;
    embeddedNode.rotation = ccbFileNode.rotation;
    embeddedNode.scale = ccbFileNode.scale;
    embeddedNode.tag = ccbFileNode.tag;
    embeddedNode.visible = YES;
    //embeddedNode.ignoreAnchorPointForPosition = ccbFileNode.ignoreAnchorPointForPosition;

    [actionManager moveAnimationsFromNode:ccbFileNode toNode:embeddedNode];

    ccbFileNode.ccbFile = NULL;

    node = embeddedNode;
}

...but I'm not sure that fiddling with this is going to fix it the next data read seems to just get the value of the file itself and not that "middle" or "instance" node - its like that data has been thrown away somehow.

sarah-j-smith avatar Apr 29 '13 03:04 sarah-j-smith

I've done a minimal proof with CCB files and an accompanying iOS project.

https://www.dropbox.com/sh/pme8elg7rejf9io/NTcWvv5DaR

If those dropbox files are inaccessible let me know.

sarah-j-smith avatar Apr 29 '13 05:04 sarah-j-smith

OK, I've dug around in CCBReader.m/h and I don't actually think the problem is there, it seems as though the data is never being written by CocosBuilder.

I'll see if the experts come up with anything on this before I fool around with it any more.

sarah-j-smith avatar Apr 29 '13 06:04 sarah-j-smith

Thanks for your research! I will have a look at this!

vlidholt avatar May 08 '13 01:05 vlidholt

Great! Let me know if I can help.

sarah-j-smith avatar May 09 '13 10:05 sarah-j-smith

I ran into this yesterday, and didn't find this issue report until just now. Any word on if this will be fixed soon? I want to hand my project to the technical artist and let him set properties in the editor as he goes.

almo2001 avatar Jun 26 '13 14:06 almo2001

I'm working around this at present by copying-and-pasting the node with all its properties over and over; in whatever scene its used in. It's pretty nasty, and a bit error-prone but its the only way at present. I've written extra error-checking code in my project to try to catch cut-n-paste errors.

sarah-j-smith avatar Jun 27 '13 05:06 sarah-j-smith

Ok, thanks for the tip. I was considering using different CCBs for the different settings, as there aren't that many in my project. Not sure which I'll go with. :)

almo2001 avatar Jun 27 '13 10:06 almo2001

Where are we at with this? This is a pretty serious bug that comes up in regular use.

rikthevik avatar Sep 16 '13 16:09 rikthevik

Did anyone ever solve this issue?

loanvlg avatar Mar 28 '15 00:03 loanvlg

@loanvlg I don't think so. CocosBuilder is not supported anymore (I still use it). If you want more features, try SpriteBuilder.com :)

sortris avatar Mar 28 '15 00:03 sortris

@sortris Yeah, would like to but it doesn't support cocos2d-x unfortunately... I am curious though if there is a way to cheat it by building with SpriteBuilder a project that works with CocosBuilder?

loanvlg avatar Mar 28 '15 01:03 loanvlg