1 tolua++ 目录下创建一个目录zgame
编写zgExtension.pkg
$#include "ZgExtension.h"$pfile "zgame/ZgameAnimation.pkg"$pfile "zgame/TableView.pkg"$pfile "zgame/Zgame.pkg"$pfile "zgame/GraySprite.pkg"
再增加其他的pkg文件, 目的是将几个c++文件, 打包成一个ZgExtension.cpp文件
2 编辑basic.lua, 增加子pkg文件, 然后运行build.sh, 就会生成ZgExtension.cpp文件
3. 编辑ZgExtension.h文件
#ifndef __LUAzsw_H_#define __LUAzsw_H_extern "C" {#include "tolua++.h"#include "tolua_fix.h"}#include
4. 将这2个文件放到项目工程自己的toLua的目录下, 然后在MainGame.cpp(AppDelegate.cpp),加上
#include "toLua/ZgExtension.h"
lua中就可以调用到c++的函数了