【教程分享】cocos2dx3.0rc导出自定义类到lua的方法详细步骤

我也遇到了这样的问题~~请问你解决了么?这是我的QQ:642888097

可以顺利生成cpp和hpp文件 , 到第5步,就没办法继续下去了!!!!
Undefined symbols for architecture i386:
“register_all_myclass(lua_State*)”, referenced from:
cocos2d::LuaStack::init() in libluabindings iOS.a(CCLuaStack.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

求官方解决方案

cpp和hpp都生成了,貌似也注册成功了,但是硬是出现一个错误hello.lua:13: attempt to index global ‘TestScene’ (a nil value)
hello.lua :
require “Cocos2d”
require “Cocos2dConstants”
– cclog
cclog = function(…)
print(string.format(…))
end

local scene = cc.Scene:create()
cc.Director:getInstance():runWithScene(scene)
cclog(“1”)
local sprite = TestScene:create()
scene:addChild(sprite)
cclog(“2”)

TestScene是一个静态方法create一个精灵,继承sprite,很简单,求大神帮助为什么找不到testscene

— Begin quote from ____

引用第23楼wkhhwf于2014-06-26 20:56发表的 :
cpp和hpp都生成了,貌似也注册成功了,但是硬是出现一个错误hello.lua:13: attempt to index global ‘TestScene’ (a nil value)
hello.lua :
require “Cocos2d”
require “Cocos2dConstants”
– cclog
http://www.cocoachina.com/bbs/job.php?action=topost&tid=196416&pid=989892

— End quote

请问你的问题解决了吗?

— Begin quote from ____

引用第23楼wkhhwf于2014-06-26 20:56发表的 :
cpp和hpp都生成了,貌似也注册成功了,但是硬是出现一个错误hello.lua:13: attempt to index global ‘TestScene’ (a nil value)
hello.lua :
require “Cocos2d”
require “Cocos2dConstants”
– cclog
http://www.cocoachina.com/bbs/job.php?action=topost&tid=196416&pid=989892

— End quote

请问你的问题解决了吗?如果解决了给我说一下可以吗,我的QQ:604757644

lz,纠结绑定c++到lua好久了,终于发现一个靠谱的帖子。
不过我这有个问题出现在第4步。执行genbindings_myclass.py过程中脚本generator.py时报错。
执行脚本后的所有信息:
F:\cc\cc-3.0_mybase\tools\tolua>python genbindings_myclass.py
PYTHON_BIN not defined, use current python.
generating userconf.ini…
Generating bindings for myclass…
Using userconfig
(‘androidndkdir’, ‘F:\cc\adt-bundle-windows-x86_64-20140321\android-ndk-r9
d’), (‘clangllvmdir’, ‘F:\cc\adt-bundle-windows-x86_64-20140321\android-ndk-r
9d\toolchains\llvm-3.3\prebuilt\windows-x86_64’), (‘cocosdir’, ‘F:\cc\cc-3
.0_mybase’), (‘cxxgeneratordir’, ‘F:\cc\cc-3.0_mybase\tools\bindings-generat
or’), (‘extra_flags’, ‘-D__WCHAR_MAX__=0x7fffffff -U__MINGW32__’)]
Traceback (most recent call last):
File “F:\cc\cc-3.0_mybase\tools\bindings-generator/generator.py”, line 1294, i
n
main()
File “F:\cc\cc-3.0_mybase\tools\bindings-generator/generator.py”, line 1234, i
n main
raise Exception(“Section not found in config file”)
Exception: Section not found in config file

Generating lua bindings fails.

麻烦lz帮忙看看是怎么回事,

一直出现一个错误
C:\cocos2d-x\project\MyLuaGame\frameworks\cocos2d-x\tools\tolua>python genbindin
gs_myclass.py
PYTHON_BIN not defined, use current python.
generating userconf.ini…
Generating bindings for myclass…
Traceback (most recent call last):
File “C:\cocos2d-x\project\MyLuaGame\frameworks\cocos2d-x\tools\bindings-gener
ator/generator.py”, line 11, in
import yaml
ImportError: No module named yaml

Generating lua bindings fails.

请问这个yaml是什么。。怎么解决啊

一个个的去搜索。。发现前辈也遇到这个问题 。他的解决方法。。我正在WINDOWS上尝试安装

http://www.cnblogs.com/shrimps/p/ubuntu-cocos2d-x-lua-binding-generator-env.html
忘记贴上地址了。

看完README后只能说悲剧已经发生,windows上最好装32位的python2.7=.= 否则。。郁闷之处不用多说

在按照readMe做了后还是出现了如下的错误提示。跟上面的同学遇到的问题一样。请问有人解决了么

Traceback (most recent call last):
File “/Users/wangping/Desktop/cocos3.1.1Project/MyLuaGame/frameworks/cocos2d-x/tools/bindings-generator/generator.py”, line 1306, in
main()
File “/Users/wangping/Desktop/cocos3.1.1Project/MyLuaGame/frameworks/cocos2d-x/tools/bindings-generator/generator.py”, line 1282, in main
‘headers’: (config.get(s, ‘headers’ , 0, dict(userconfig.items(‘DEFAULT’)))),
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py”, line 623, in get
return self._interpolate(section, option, value, d)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py”, line 691, in _interpolate
self._interpolate_some(option, L, rawval, section, vars, 1)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py”, line 723, in _interpolate_some
option, section, rest, var)
InterpolationMissingOptionError: Bad value substitution:
section:
option : headers
key : cocosdir
rawval : /cocos/cocos2d.h (cocosdir)s/cocos/audio/include/SimpleAudioEngine.h (cocosdir)s/cocos/ui/CCProtectedNode.h

:7: 不错的教程

=。=,今天又尝试了一下 并且查找了一下资源。才发现。。我没有仔细的读readme啊。。。,上面说一定要用ndkr9b…而我用的r9d…真是悲剧。据这个http://www.cocoachina.com/bbs/read.php?tid=195350帖子上说,应该就是这货的问题了

标记一下,备用

这个是需要安python的yaml插件,搜索安装即可

楼主,执行到第六步,如何编译运行呢?

执行 ./genbindings_myclass.py 后出现 下面的错误 好像是没有 c version的cheetah 是什么意思 有知道的吗?

You don’t have the C version of NameMapper installed! I’m disabling Cheetah’s useStackFrames option as it is painfully slow with the Python version of NameMapper. You should get a copy of Cheetah with the compiled C version of NameMapper.

感谢楼主~~~~~~~:14::14::14:

你这个报错是因为.ini文件命名跟里面的命名不同的bug吧