creator_to_cocos2dx
creator_to_cocos2dx copied to clipboard
[feature] Custom Class integration like Cocos Studio C++
Discuss
https://discuss.cocos2d-x.org/t/creator-custom-class-integration-like-cocos-studio-c/42471
this feature is put forward and doing by @pabitrapadhy
Example Repo
https://github.com/pabitrapadhy/CocosCreatorCppDemo
Introduce from Discuss
Earlier, I have been programming cocos2dx games using Cocos Studio. The concept of Custom Class and ability to create a separate Layer csd file was pretty handy.
Since, Cocos Creator has no functionality to directly read CustomClass name, neither to export only Layer files. I’ve been working to bridge this issue.
These are the following things that I’ve added to the project -
Used specific naming convention i.e “Layer_ClassName_NodeName” in nodes, that I can attach custom class. The reason behind it to create a runtime class of that type from the string, directly while reading the ccreator file. Ex - CustomLayer class in my project. (Used Factory Pattern).
Subclassed the reader to create the Scene of custom type, while reading from the ccreator file directly. Ex - CustomScene class in my project. So, by doing this the CustomLayer object would be created, while reading the Scene or if you want to create objects in the runtime, it will do so.
Wrote meta codes, to handle for - CustomScene, CustomLayer, ButtonClickEvent etc.
Related Discusses
https://discuss.cocos2d-x.org/t/help-with-creator-cpp-layering/42468 https://discuss.cocos2d-x.org/t/solved-creator-cpp-custom-class-integration/42469