cocos2d-x 3.3 导入lua扩展库

前端之家收集整理的这篇文章主要介绍了cocos2d-x 3.3 导入lua扩展库前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

cocos2d-x 导入lua扩展库有几个点需要注意:

1、cocos2d-x 中的lua版本为5.1.4,所导入的lua库需要对应相应的版本库。

2、在vs 2012 中编译cocos2d-x ,添加的C文件需要注明用C编译,如一般.h文件需要这样写

#ifndef __LUA_LPEG_H_
#define __LUA_LPEG_H_


#if __cplusplus
extern "C" {
#endif

#include "lua.h"
#include "lauxlib.h"
int luaopen_lpeg(lua_State *L);


#if __cplusplus
}
#endif
//int luaopen_lpeg(lua_State *L);


#endif

3、在cocos2d-x 中lua_extensions 中需要为添加相应头文件,相对应的lua库注册,在static luaL_Reg luax_exts[] 中添加需要添加代码{"lpeg",luaopen_lpeg}。

4、android 支持,在Android.mk中添加 增加文件

原文链接:https://www.f2er.com/cocos2dx/344434.html

猜你在找的Cocos2d-x相关文章