C++ support for Cocos Creator

I am working on the creator plugin. Currently i finished most things. The steps to use the plugin is:

You you find all needed source codes are copied to NATIVE_PROJECT_ROOT/Classes/reader(it is NATIVE_PROJECT_ROOT/frameworks/runtime-src/Classes in lua), and all resources are copied to NATIVE_PROJECT_ROOT/Resources/creator(it is NATIVE_PROJECT_ROOT/res/creator in lua).

You can just use the readers and resources in your project to have a test. If using c++, then you need to add these codes

#include "reader/CreatorReader.h"

auto reader = creator::CreatorReader::createWithFilename("creator/CreatorSprites.ccreator");
reader->setup();
auto scene = reader->getSceneGraph();
director->runWithScene(scene);

If using lua, then you need to add these codes in c++ and lua.

add binding codes in c++

#include "reader/CreatorReaderBinding.h"

...

register_all_creator_reader_manual(L);

use in lua

local creatorReader = cc.CreatorReader:createWithFilename('creator/CreatorSprites.ccreator')
creatorReader:setup()
local scene = creatorReader:getSceneGraph()
cc.Director:getInstance():replaceScene(scene)

Please let me know if you meet any problem. Thanks.

3 Likes

Thanks for sharing details.
So i tried all steps.
I have problem with loading CreatorReader.

This line gives me 62 errors.
I am testing on cocos2d-x 3.14.1 C++ VS-2013

Update:
Working fine on Android.

It seems it is the error of reader, not in plugin. @ricardo did you try the reader in windows? I haven’t tried it on windows, i will have a try.

@zhangxm no, only on mac.

@smitpatel88 could you try it with vs-2015? thanks.

@ricardo i tested in VS2015, the same issue. I will try to fix it if possible.

@zhangxm I guess it is fixed. I made the changes that you suggested:

@ricardo yep, it is fixed.
@smitpatel88 could you please try again.

Edit: you should sync the repo before trying.

IMPORTANT:

New repository is here:

Moved from my account to the cocos2d organization.

1 Like

Yes, now its working.

Tried with this new repository.
@ricardo
Can you tell me how we can fetch the individual elements from creator scene?
Also how to give callback funct to buttons, etc?
Thanks.

@smitpatel88 i think you can use scene node to get other child by name, such as

auto reader = creator::createWithFilename(...);
reader->setup();
auto scene = reader->getSceneGraph();

scene->getChildByName("");

It is just my guess. Let’s wait @ricardo’s answer.

事例工程编译不过啊,rapidxml_sax3.hpp找不到。

yes, as @zhangxm said.
just get the node by name, and the add the callback manually.

1 Like

:heart: GREAT work!!! @ricardo very impressive, especially how persistent you are!

@ricardo Finally c++ thing inside creator 1.4. very soon I am about to implement. I am excited to work with it my first own game to develop with creator 1.4. Thanks a lot.

I’d be a little wary still. I’m reluctantly using it because some of my team members work better with GUIs than code, but it’s closed source and feels very much like beta quality software still, so if stuff breaks, you’re at the mercy of the Cocos developers and their release cycles, bureaucracy, etc. Scary enough for me not to try my luck betting a production game on it yet.

5 Likes

well, thanks for your info. If this is what happen, its better to try develop project in cocos studio with cocos2dx-3.10 because studio file is possible to import in creator now. still i have 1 month before to start coding for my project, so lets see if any update comes in between.

You can use cocos2d-x 3.14 with cocos studio no problem. You just need to copy cocos studio files from old cocos2d-x 3.10 project.

can you explain how to make it work with 3.14 because i don’t see any libraries of cocos studio in 3.14. that will be great help for me because between 3.10 to 3.14 lots of changes while my target platform is Android for the project.

cocos/editor-support/cocostudio - runtimes are here untouched. The different is with project template, in 3.14 you don’t have cocosstudio directory + ccs/cfg/udf files.

HI @ricardo i built successfully the c++ creator but when i try to create my own scene and complie it, i dont see any ‘myscene.ccreator’ in the resource folder.

Edit: i solved the issues. The reason i used drag and drop texture directly to the scene editor instead of using node library and put texture into it. When compile it, the console log just got some errors while parsing data. Dont know why.