Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Created November 3, 2014 15:29
Show Gist options
  • Save yasuharu519/5d04ecb27eb05a546795 to your computer and use it in GitHub Desktop.
Save yasuharu519/5d04ecb27eb05a546795 to your computer and use it in GitHub Desktop.
CSB Load sample for cocos2d-x 3.3rc0
#include "HelloWorldScene.h"
#include "editor-support/cocostudio/CocoStudio.h"
USING_NS_CC;
Scene* HelloWorld::createScene()
{
auto scene = Scene::create();
auto layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
auto node = CSLoader::getInstance()->createNodeFromProtocolBuffers("MainScene.csb");
this->addChild(node);
return true;
}
@lishunan246
Copy link

Great example!

Copy link

ghost commented Feb 18, 2015

I am having MainScene.csb in "assert/res" so i have written this code.

auto node = CSLoader::getInstance()->createNodeFromProtocolBuffers("res/MainScene.csb");
this->addChild(node,0);

but it shows me error saying
Assert failed: Argument must be non-nil in addchild()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment