Convert C++ code to javascript code

Convert C++ code to javascript code
0.0 0


Hi every one
I have a code:

m_pMeshCommand = new MeshCommand();
m_pMeshCommand->genMaterialID(0, m_ProgramState, m_RenderMesh->getVertexBuffer(), m_RenderMesh->getVertexBuffer(), m_BlendFunc);
m_pMeshCommand->init(_globalZOrder, textureID, programstate, m_BlendFunc, m_RenderMesh->getVertexBuffer(),m_RenderMesh->getIndexBuffer(),(GLenum)m_RenderMesh->getPrimitiveType(), (GLenum)m_RenderMesh->getIndexFormat(), m_RenderMesh->getIndexCount(), transform);

m_pMeshCommand->setDisplayColor(Vec4(color.r, color.g, color.b, color.a));

I need convert it to javascript language, but I don’t know how to use MeshCommand on jsb cocos2d.
Does anyone help me? Please.


I have tried to add c++ functions to cocos2d js . I have tried to use jsb.reflection.callStaticMethod to call static function in c++ class and i have tried to Bind a custom class to js runtime But it does not work
Can u help me please
please advice


Follow this guide. It works.


Generating bindings for cocos2dx…
Using userconfig
Traceback (most recent call last):
File “C:\Users\User\Desktop\bidings-example-v3\frameworks\cocos2d-x\tools\bind
ings-generator/”, line 1550, in
File “C:\Users\User\Desktop\bidings-example-v3\frameworks\cocos2d-x\tools\bind
ings-generator/”, line 1468, in main
clang_lib_path = os.path.join(userconfig.get(‘DEFAULT’, ‘cxxgeneratordir’),
File “C:\Python27\lib\”, line 618, in get
raise NoOptionError(option, section)
NoOptionError: No option ‘cxxgeneratordir’ in section: ‘DEFAULT’

Generating javascript bindings fails.

how to fixed it? any hepl please


Be sure you have these in file:

project_root = os.path.abspath(os.path.join(os.path.dirname(file), ‘…’, ‘…’))
cxx_generator_root = os.path.abspath(os.path.join(project_root, ‘bindings-generator’))

config.set(‘DEFAULT’, ‘cxxgeneratordir’, cxx_generator_root)

It’s just the path to bindings folder. You can name them as you want.


Maybe it’s not important anymore, but if you have a JSB generator don’t work, because this reason. The problem is that don’t see userconf.ini. There are is wrong search of this file in row 1465'userconf.ini'). Write there path to your userconfig file, and all work fine.