Cocos Builder generating links to subcomponents

I’ve been playing with CocosBuilder 2.0 and it’s definitely an improvement over hand coding layout for Cocos2D menus.

It does have a bit of a learning curve, especially with the lack of documentation (which will likely linger for a while).

Much of the tool is non-intuitive in the world of wysiwyg, but if you are writing or are maintaining hundreds of lines of code for this regard it’s worth it.  Just like Interface Builder is to Objective-C presentation layers, knowing the object design behind it will help you understand it.

That said, here’s a few gotchas I’ve run into.

If you are trying to connect to a property that you’ve created in the header file and are allowing the new Objective-C to generate the ivar for, beware that the ivar name is preceded with an underscore.

@property (nonatomic, assign) CCLabelTTF *myLabel;

leads to an instance variable named _myLabel unless you provide your own (no longer needed) @synthesis line.

I also noticed after following the code that they’ve provided a nice method that gets invoked after the CCB file is loaded.

- (void)didLoadFromCCB;

I would have preferred they follow Apple’s NeXT’s naming convention. They defined an awakeFromNib method. This one should have been awakeFromCCB.

I definitely would have liked a menu to open files (not just projects).  The only way i’ve found is open the project, find the file in the listing, double click it.  If it’s not listed, finagle the setting to see it.

1 thought on “Cocos Builder generating links to subcomponents

  1. bshirley Post author

    I would also add that the following bit of code is useful for presenting a transitional scene that is dismissed when the use clicks anywhere on it.

    - (void)didLoadFromCCB {
    self.isTouchEnabled = YES;

    if (IS_RETINA) {
    self.habitatChip.scale *= 2;
    }
    }

    - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [[[AppDelegate currentAppDelegate] sceneManager] startGameLevel];
    }

    There’s also some extra code in there to manage some scaling of a CCSprite on retina displays.

Leave a Reply

Your email address will not be published. Required fields are marked *