Forums » C++ Framework » CocosBuilder Reader Ported to Cocos2d-X »
| Di Wu | CocosBuilder Reader Ported to Cocos2d-X | ||||
|---|---|---|---|---|---|
|
Added by Di Wu about 1 year ago
I just ported the CCBReader class from the popular CocosBuilder project into Cocos2d-X. It can now handle and parse .ccb files created by CocosBuilder in a Cocos2d-X project. GitHub: https://github.com/diwu/CCB-X-Reader Due to C++'s not-that-dynamic nature as compared to Objective-C, I added a new CCBClassGenerator class to handle all the dynamic stuff for this port. Make sure you have properly implemented this class before testing your own .ccb files. As of now, this project only supports .ccb (which is actually a .plist file by nature). .ccbi is currently not supported. And, as of now, this project is not quite finished yet. But the enclosing example project can run without a problem. Go take a look and let me know what you guys think. YouTube Demo: http://www.youtube.com/watch?v=QgA0fkse-AA
|
||||
| Zhe Wang | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Zhe Wang about 1 year ago
So sorry I didn't post my post in time Enjoy Coding, Enjoy Life. |
||||
| Zhe Wang | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Zhe Wang about 1 year ago
Hi, Diwu, thanks for your contribution! Eventually I refered your design and made c++ reflection easier. Enjoy Coding, Enjoy Life. |
||||
| Di Wu | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Di Wu about 1 year ago
Thanks Walzer. Really appreciated it. |
||||
| Isaac Ashdown | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Isaac Ashdown about 1 year ago
This is awesome, thanks! I've managed to get it working in my game. However, I did have some trouble with the way the reader handles strings that are in the dictionary. This was all using the win32 version of cocos2d. Here's the line that gets the file type: const char * fileType = (((CCString*) (dict->objectForKey("fileType"))) -> toStdString()).c_str(); This calls the function CCString::toStdString, which is defined like this:
This function returns a std::string which is a copy of the value of m_sString. Thus, this copy is made when the function is called on the CCString containing the fileType, and then the char* is accessed with c_str. However, when I first ran the reader, the value of fileType after the line was executed was an empty string (""). It seemed that what was happening was that the std::string returned by toStdString() was being destroyed immediately after this line was executed. This also destroyed the attached char* string. Why the value of fileType was "" rather than some random bit of memory I don't know. Perhaps it's my compiler settings. Perhaps all of this is my compiler settings! But anyway, I got it working by changing the toStdString function to this:
This seems like it might be dangerous if the value returned anywhere in the engine is modified. But at least for my game it all seems fine. Anyway, I hope that makes sense. Thanks again for the port! Now if only someone would port cocosbuilder itself so I don't have to run it on a VMWare box Isaac |
||||
| Di Wu | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Di Wu about 1 year ago
Hi Isaac, Thanks for the feedback. I'm super excited that the port is working in your game!! Since this function CCString::toStdString() is used in a lot of places in the port, do you find all of them not working, or just that one or two places you mentioned in your feedback? Besides, based on my understanding of your description, this is more likely to be a Cocos2d-X issue on Win32. You provided a way to fix it in the Cocos2d-X source. However, if the Cocos2d-X source has to be remain unchanged, do you have any suggestions that we may fix it on the CCBReader port part? Such as adding some runtime check? Cheers, Di |
||||
| baiqi wu | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by baiqi wu about 1 year ago
I have download the sample project on github --- CocosBuilder Reader Ported to Cocos2d-X(http://www.cocos2d-x.org/boards/6/topics/10755) 05-11 08:46:07.699: E/AndroidRuntime(3118): FATAL EXCEPTION: main And the visual studio also throw the error like: 1>CCBReader.obj : error LNK2001: unresolved external symbol "public: virtual float __thiscall cocos2d::CCParticleSystem::getTimeScale(void)" (?getTimeScale@CCParticleSystem@cocos2d@ |
||||
| Di Wu | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Di Wu about 1 year ago
Did you modify the build_native.sh and change the path params into your own before compiling? Example: #change them into your own params |
||||
| baiqi wu | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by baiqi wu about 1 year ago
Hi, I built it on Windows and I did not use the build_native.sh this is my AndroidMake File LOCAL_PATH := $(call my-dir) LOCAL_MODULE := game LOCAL_SRC_FILES := main.cpp \ LOCAL_C_INCLUDES := ../../libs/cocos2dx \ LOCAL_SHARED_LIBRARIES := cocosdenshion_shared box2d_shared chipmunk_shared LOCAL_STATIC_LIBRARIES := png_static_prebuilt include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) Capture.PNG (20.5 kB) |
||||
| baiqi wu | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by baiqi wu about 1 year ago
Hi, Thank you for your promotion reply. |
||||
| Andrew Rylov | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Andrew Rylov about 1 year ago
Hello. In lua-script variables of type "Owner var" available. And selectors in ccb with Target="Owner" are binded with functions from lua-script. To implement this functionality I have made some modifications in CCBCustomClassProtocol class: 1. "bool callbackSetChildren(const char* name, cocos2d::CCObject* node)" It is necessary to define types of variables in lua-script, not just CCObject type. 2. "cocos2d::SEL_MenuHandler callbackGetSelectors(const char* selectorName)" Can you apply this changed in main branch? |
||||
| Jiye Shen | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Added by Jiye Shen about 1 year ago
What version cocosbuilder you used ? I both try v1.0 and v1.1, when i try to use v1.0, it does not run at all, but use v1.1, i get "Cocos2d: WARNING! Trying to load file made with a newer version of CocosBuilder, please update the CCBReader class" in console. v 1.1: but in the example, the fileVersion is 2. |
||||
| 叫NPC 我的名字 | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
Did you resolve this problem? I have the same problem . |
||||
| Zhe Wang | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
CocosBuilder v1.1-beta changed ccb file format A LOT, which is named v3. Enjoy Coding, Enjoy Life. |
||||
| 叫NPC 我的名字 | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
I reslove this problem. |
||||
| JP Sarda | RE: CocosBuilder Reader Ported to Cocos2d-X | ||||
|
What's the status for CocosBuilder v2? Is there somebody working on the import of .ccb(i) files generated with CocosBuilder v2? |
(1-15/15)


