Name: creator_to_cocos2dx
Owner: cocos2d
Description: Creator plugin to support C++& Lua in cocos2d-x
Created: 2017-02-16 03:50:58.0
Updated: 2018-05-17 09:09:22.0
Pushed: 2018-05-11 04:49:57.0
Size: 6693
Language: C++
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Table of Contents generated with DocToc
Given that Creator uses a component based model to create its objects, and cocos2d-x has its monolithic structure, it is only possible to support a limited subset of Creator features.
Supported nodes:
Scene
Sprite
Canvas
(but only one per scene)ScrollView
Label
EditBox
ParticleSystem
TiledMap
Button
ProgressBar
RichText
:line height
because cocos2d-x's RichText
doesn't support this features.horizontal alignment
because cocos2d-x's RichText
doesn't support this features. Though cocos2d-x v3.16+ supports this feature, but it is hard for plugin to danymicly supporting it according cocos2d-x's version.SpineSkeleton
Widget
: only supports AlignOnce
Animations
VideoPlayer
: iOS should add MediaPlayer.framework
to the projectWebView
Slider
Toggle
ToggleGroup
PageView
Mask
Collider
Prefab
DragonBones
MotionStreak
Supporting JavaScript scripts would be overkill. If you need JavaScript scripting support, just use Creator.
Can fetch this branch and run cpp-empty-test
or lua-empty-test
. The branch based on v3.15, don't forget to update external libraries.
Currently support on Mac, iOS, Android and Windows.
You will find:
NATIVE_PROJECT_ROOT/Classes/reader(it is NATIVE_PROJECT_ROOT/frameworks/runtime-src/Classes/reader for lua project)
NATIVE_PROJECT_ROOT/Resources/creator(it is NATIVE_PROJECT_ROOT/frameworks/runtime-src/Resources/creator for lua project)
For cpp projects, just add reader
into header search path.
For lua projects, add the following header paths:
If developing for Android, can just use existing Android.mk
, for example, use the Android.mk
into your game's Android.mk
like this:
L_PATH := $(call my-dir)
ude $(CLEAR_VARS)
L_MODULE := MyGame_shared
L_MODULE_FILENAME := libMyGame
L_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
L_C_INCLUDES := $(LOCAL_PATH)/../../Classes
OCOS_HEADER_ANDROID_BEGIN
OCOS_HEADER_ANDROID_END
L_STATIC_LIBRARIES := cocos2dx_static
CAL_STATIC_LIBRARIES += creator_reader_lua # for lua project
L_STATIC_LIBRARIES += creator_reader # add dependence
OCOS_LIB_ANDROID_BEGIN
OCOS_LIB_ANDROID_END
ude $(BUILD_SHARED_LIBRARY)
ll import-module,.)
ll import-module, ./../../Classes/reader) # import module path
If developing with Lua, then need to add CreatorReaderBinding.cpp
into plugin's Android.mk.
ygame.cpp
lude "reader/CreatorReader.h"
some_function()
creator::CreatorReader* reader = creator::CreatorReader::createWithFilename("creator/scenes/sprites/CreatorSprites.ccreator");
// will create the needed spritesheets + design resolution
reader->setup();
// get the scene graph
Scene* scene = reader->getSceneGraph();
// ...and use it
Director::getInstance()->replaceScene(scene);
Register creator binding codes in c++
lude "reader/lua-bindings/creator_reader_bindings.hpp"
ster_creator_reader_manual(L);
Use in lua
l creatorReader = creator.CreatorReader:createWithFilename('creator/CreatorSprites.ccreator')
torReader:setup()
l scene = creatorReader:getSceneGraph()
irector:getInstance():replaceScene(scene)
ColliderManager
is used to manage collisions. Every scene has an instance of ColliderManager
. You can use it like this to listen collision events:
tor::CreatorReader* reader = creator::CreatorReader::createWithFilename("creator/CreatorSprites.ccreator");
ill create the needed spritesheets + design resolution
er->setup();
et the scene graph
e* scene = reader->getSceneGraph();
colliderManager = scene->getColliderManager();
iderManager->registerCollitionCallback([=](creator::Contract::CollisionType type,
creator::Collider* collider1,
creator::Collider* collider2) {
if (type == creator::Contract::CollisionType::ENTER)
colliderManager->enableDebugDraw(true);
if (type == creator::Contract::CollisionType::EXIT)
colliderManager->enableDebugDraw(false);
");
More features of colliderManager
can refer to the header file.
You can install the released version from Creator, or you can copy creator_project/packages/creator_luacpp_support
into Cocos Creator project/packages
, then you will see the plugin in Project -> LuaCPP Support.