首页 > 代码库 > 新随笔
新随笔
Table of Contents
- 1 cocos3.3 luabinding详解
- 1.1 1.pyyaml的安装
- 1.2 2.cheetahr的安装
- 1.3 3.编写.ini文件
- 1.4 4.注册到Lua
cocos3.3 luabinding详解
1.pyyaml的安装
python -m easyinstall pyyaml
2.cheetahr的安装
https://codeload.github.com/cheetahtemplate/cheetah/legacy.zip/v2.4.0 cmd下运行python setup.py install
3.编写.ini文件
模板 [cocos2dxcustom]
prefix = cocos2dxcustom
targetnamespace = cc
androidheaders = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
androidflags = -DSIZETDEFINED_
clangheaders = -I%(clangllvmdir)s/lib/clang/3.3/include
clangflags = -nostdinc -x c++ -std=c++11
cocosheaders = -I%(cocosdir)s/cocos -I%(cocosdir)s/my -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/ui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s
cocosflags = -DANDROID -DCOCOS2DJAVASCRIPT
cxxgeneratorheaders =
extraarguments = %(androidheaders)s %(clangheaders)s %(cxxgeneratorheaders)s %(cocosheaders)s %(androidflags)s %(clangflags)s %(cocosflags)s %(extraflags)s
headers = %(cocosdir)s/cocos/my/CustomClass.h
classes = CustomClass.*
# regular expressions, they will not be surrounded by "^\)". If you want to skip a whole class, just # add a single "*" as functions. See bellow for several examples. A special class name is "*", which
skip =
renamefunctions =
renameclasses =
removeprefix =
classeshavenoparents =
baseclassestoskip =
abstractclasses =
scriptcontrolcpp = no
4.注册到Lua
LuaStack *stack = engine->getLuaStack(); auto L = stack->getLuaState(); if (L) { luagetglobal(L, "G"); registerallcocos2dxcustom(L); luasettop(L, 0); }
#if (COCOS2DDEBUG>0) if (startRuntime()) return true; #endif engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().cstr()); return true;
新随笔