Error in publishing CocosBuilder scene in cocos2d 3.0

288 views Asked by At

I am new for Xcode, Cocos2d, and I am making my first steps in CocosBuilder. I am learning from available online tutorials including RayWenderlich Game Development tutorials. While I am copying the code, sometimes I've noticed that authors miss some points, which are not obvious for new developer. In tutorial Introduction to CocosBuilder, I can't go through putting scene (*.ccbi) into Xcode I have cocos2d 3.1.0. My code:

+(CCScene *) scene
{
    CCNode * menu = [CCBReader nodeGraphFromFile:@"MainMenuScene.ccbi"];
    CCScene * scene = [CCScene node];
    [scene addChild:menu];
    return scene;
}

Xcode doesn't recognize nodeGraphFromFile even if I have made #import "CCBReader.h" and also tried another method sceneWithNodeGraphFromFile also doesn't recognize.

CCScene *s= [CCBReader sceneWithNodeGraphFromFile:@"MainMenuScene.ccbi"];

Can anyone help to show how it look full code of publishing scene from CocosBuilder to cocos2d 3.1.0 version, I would much appreciate.

Unfortunately I can't upload my screenshots.

2

There are 2 answers

1
CodeSmile On BEST ANSWER

The CocosBuilder project is deprecated, meaning it is no longer in development (last update May 2013). You can still use CB to create applications with cocos2d-iphone v2.x though, but it won't work with cocos2d-iphone v3.

So in short: you can't use CocosBuilder with cocos2d-iphone v3. There will always be a host of problems associated with trying to make it work, and odds are it will not be possible without modifying the cocos2d engine itself respectively the designs in CB will not match what you get when running the app.

You do have alternative options though:

  • For cocos2d-iphone v3 use SpriteBuilder, the successor to CocosBuilder. You will easily find tutorials for SB and in a couple of months my Learn SpriteBuilder book will be available, too. SpriteBuilder itself is available on the Mac App Store.

  • Cocos2d-x users should be using Cocos Studio. SpriteBuilder does not support cocos2d-x.

The SpriteBuilder option also does not require you to manually add the CCBReader files, as they are part of cocos2d v3 which is why there will likely be various conflicts/errors if you try to add the CocosBuilder CCBReader files to a v3 project. SpriteBuilder releases are synchronized with cocos2d-iphone releases so there will not be version-mismatch issues, plus SB can update existing projects to the latest cocos2d-iphone version.

Note however that SpriteBuilder can not import projects or CCB files previously created with CocosBuilder.

4
Nithin Haridas On

As a checklist,

Make sure you have the CCBReader.h added to your project. It is available here. https://github.com/cocos2d/CCBReader

Then,

All the ccbi files and other resources should also be added to the project.

Once done, your above code should work.

Start the scene as follows

[[CCDirector sharedDirector] runWithScene:newScene];