CocosBuilder
CocosBuilder copied to clipboard
Overriding of custom properties not working
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:
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.
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.
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.
Thanks for your research! I will have a look at this!
Great! Let me know if I can help.
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.
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.
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. :)
Where are we at with this? This is a pretty serious bug that comes up in regular use.
Did anyone ever solve this issue?
@loanvlg I don't think so. CocosBuilder is not supported anymore (I still use it). If you want more features, try SpriteBuilder.com :)
@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?