求cocos2d-x javascript binding自定义类的教程

学习cocos2d-x javascript, 遇到绑定的问题, 在google了好多天, 发现教程比较少, 但遇到的麻烦比较多

  1. test中的std::string会报错, 请含有std::string的函数都删除, 编译就通过了
  2. test中的c++类如果要include “cocos2d.h”, 该怎么实现呢?
  3. tojs中需要配置哪些东西才能正确地运行? 我运行到的地方如下, 错误指向ndk中, 便不知道该做些什么了?

我困惑了很久, 企盼高手指教

ritoutoutekiMacBook-Pro:~ lidongdong$ cd /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/tojs
ritoutoutekiMacBook-Pro:tojs lidongdong$ ./genbindings.sh
Paths
NDK_ROOT: /Users/lidongdong/Dev/Android/Tools/android-ndk-r8
CLANG_ROOT: /Users/lidongdong/bin/clang+llvm-3.1
PYTHON_BIN: /opt/local/bin/python2.7
COCOS2DX_ROOT: /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1
CXX_GENERATOR_ROOT: /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/cxx-generator
TO_JS_ROOT: /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/tojs

generating userconf.ini…

androidndkdir=/Users/lidongdong/Dev/Android/Tools/android-ndk-r8
clangllvmdir=/Users/lidongdong/bin/clang+llvm-3.1
cocosdir=/Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1
cxxgeneratordir=/Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/cxx-generator


Generating bindings for cocos2dx…

  • LD_LIBRARY_PATH=/Users/lidongdong/bin/clang+llvm-3.1/lib
  • /opt/local/bin/python2.7 /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/cxx-generator/generator.py /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/tojs/cocos2dx.ini -s cocos2d-x -o /Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/tojs/javascript
    Using userconfig
    (‘androidndkdir’, ‘/Users/lidongdong/Dev/Android/Tools/android-ndk-r8’), (‘clangllvmdir’, ‘/Users/lidongdong/bin/clang+llvm-3.1’), (‘cocosdir’, ‘/Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1’), (‘cxxgeneratordir’, ‘/Users/lidongdong/Dev/Android/Tools/cocos2d-2.1beta3-x-2.1.1/tools/cxx-generator’)]

… Generating bindings for target spidermonkey

… … Processing section cocos2d-x

====
Errors in parsing headers:

  1. <severity = Fatal,
    location = <SourceLocation file ‘/Users/lidongdong/Dev/Android/Tools/android-ndk-r8/platforms/android-14/arch-arm/usr/include/android/log.h’, line 70, column 10>,
    details = “‘stdarg.h’ file not found”>
    ====

*** Found errors - can not continue

看这个教程吧:http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_bind_C++_to_Javascript

  1. test中的c++类如果要include “cocos2d.h”, 该怎么实现呢?
    照着 cocos2d/tools/tojs/cocos2dx.ini 配就可以了。昨天查了半天后来才在英文论坛上找到。文档太分散啊,建议cocos2d能有个资料汇总的地方,把所有坑都集中起来,最好中英文都有。

??是否能提供修改後,能使用#include "cocos2d.h"的ini?以供?考???。:slight_smile:

— Begin quote from ____

lp43 发表于 2013-9-13 15:13 url

??是否能提供修改後,能使用#include "cocos2d.h"的ini?以供?考???。

— End quote

就是这个啊:cocos2d/tools/tojs/cocos2dx.ini
下载了cocos2d-x后自带的

看这个教程吧:http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_bind_C++_to_Javascript

  1. test中的c++类如果要include “cocos2d.h”, 该怎么实现呢?
    照着 cocos2d/tools/tojs/cocos2dx.ini 配就可以了。昨天查了半天后来才在英文论坛上找到。文档太分散啊,建议cocos2d能有个资料汇总的地方,把所有坑都集中起来,最好中英文都有。

??是否能提供修改後,能使用#include "cocos2d.h"的ini?以供?考???。:slight_smile:

— Begin quote from ____

lp43 发表于 2013-9-13 15:13 url

??是否能提供修改後,能使用#include "cocos2d.h"的ini?以供?考???。

— End quote

就是这个啊:cocos2d/tools/tojs/cocos2dx.ini
下载了cocos2d-x后自带的