GithubHelp home page GithubHelp logo

rudolfcn / creator_to_cocos2dx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cocos2d/creator_to_cocos2dx

0.0 2.0 0.0 4.97 MB

Creator plugin to support C++& Lua in cocos2d-x

Makefile 0.08% Python 8.26% JavaScript 15.03% HTML 0.26% CSS 0.25% C++ 75.86% C 0.26%

creator_to_cocos2dx's Introduction

Table of Contents generated with DocToc

Creator support for Cocos2d-x

Requirements

  • cocos2d-x: v3.14+
  • Cocos Creator: v1.4+

Limitations

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: need cocos2d-x 3.16+ to support img tag, refer to this issue for detail information
  • SpineSkeleton
  • Widget: only supports AlignOnce
  • Animations: only supports linear animation
  • VideoPlayer: iOS should add MediaPlayer.framework to the project
  • WebView
  • Slider
  • Toggle
  • ToggleGroup
  • PageView
  • Mask

Supporting JavaScript scripts would be overkill. If you need JavaScript scripting support, just use Creator.

How to generate the needed files

  • download and install Cocos Creator
  • use Cocos Creator to open creator_project
  • click Project -> LuaCPP Support -> Setup Target Project
  • fill in Project Path, it is a c++ or lua project created by cocos2d-x(3.14+) console
  • click Build

You will find:

  • all needed source codes are generated into NATIVE_PROJECT_ROOT/Classes/reader(it is NATIVE_PROJECT_ROOT/frameworks/runtime-src/Classes/reader for lua project)
  • all needed resources are generated into NATIVE_PROJECT_ROOT/Resources/creator(it is NATIVE_PROJECT_ROOT/frameworks/runtime-src/Resources/creator for lua project)

Using it from C++

// mygame.cpp

#include "reader/CreatorReader.h"

void some_function()
{
    creator::CreatorReader* reader = creator::CreatorReader::createWithFilename("creator/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);
}

Using it from lua

Register creator 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)

Use the plugin in your Cocos Creator project

Currently, the plugin is not completed enough, so we don't put it into Cocos Creator plugin store. But you can copy creator_project/packages/creator_luacpp_support into Cocos Creator project/packages, then you will see the plugin in Project -> LuaCPP Support.

creator_to_cocos2dx's People

Contributors

minggo avatar ricardoquesada avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.