All Projects → dot123 → Cocos2d Lua Sproto

dot123 / Cocos2d Lua Sproto

cocos2d-lua集成sproto协议

Labels

Projects that are alternatives of or similar to Cocos2d Lua Sproto

Mxe
MXE (M cross environment)
Stars: ✭ 858 (+6028.57%)
Mutual labels:  makefile
Tap
Stars: ✭ 12 (-14.29%)
Mutual labels:  makefile
Robopsychology
How to become a robopsychologist
Stars: ✭ 13 (-7.14%)
Mutual labels:  makefile
Buildroot Rs97
Please don't use this anymore, it's old.
Stars: ✭ 11 (-21.43%)
Mutual labels:  makefile
Toolchain
C/C++ toolchain for MiniOS
Stars: ✭ 11 (-21.43%)
Mutual labels:  makefile
Docker Node Opencv
Docker image for NodeJS with OpenCV
Stars: ✭ 12 (-14.29%)
Mutual labels:  makefile
Node Shmdb
the implementation of shmdb in node.js
Stars: ✭ 10 (-28.57%)
Mutual labels:  makefile
Xsensors
a fork of Xsensors with various improvements (GTK3, cleanup, bugfixes, enhancements)
Stars: ✭ 13 (-7.14%)
Mutual labels:  makefile
Pve Qemu Kvm
QEMU/KVM Emulator
Stars: ✭ 11 (-21.43%)
Mutual labels:  makefile
Electron Flatpak Base App
Flatpak runtime for electron apps based on the freedesktop runtime.
Stars: ✭ 13 (-7.14%)
Mutual labels:  makefile
Variantbam
Filtering and profiling of next-generational sequencing data using region-specific rules
Stars: ✭ 11 (-21.43%)
Mutual labels:  makefile
Last Makefile
The last makefile you'll ever need.
Stars: ✭ 11 (-21.43%)
Mutual labels:  makefile
Tornado Doc Chinese
Tornado 中文文档翻译.
Stars: ✭ 12 (-14.29%)
Mutual labels:  makefile
Android device semc urushi
SEMC Xperia Ray (ST18i)
Stars: ✭ 10 (-28.57%)
Mutual labels:  makefile
Elixir.mk
A (very) experimental plugins for erlang.mk to use Elixir modules in Erlang
Stars: ✭ 13 (-7.14%)
Mutual labels:  makefile
Android device oppo find7
Device tree for Oppo Find 7/7a
Stars: ✭ 10 (-28.57%)
Mutual labels:  makefile
Docker Unifi Armhf
UniFi 5 Controller for Raspberry Pi
Stars: ✭ 12 (-14.29%)
Mutual labels:  makefile
Stanford Drupal Profile
A dev / test-only version of the Drupal Hosting Service Configuration
Stars: ✭ 13 (-7.14%)
Mutual labels:  makefile
Ferret
Ferret is a free software lisp implementation for real time embedded control systems.
Stars: ✭ 878 (+6171.43%)
Mutual labels:  makefile
3d Semantic Segmentation For Scene Parsing
A new approach for the real time 3D semantic segmentation based on feature abstract and deep learning method
Stars: ✭ 13 (-7.14%)
Mutual labels:  makefile

在cocos2d-x/external/lua 目录下新建四个文件夹sproto,bitop,lpeg,lpack。然后将各自的文件放入其中,为了符合cocos2dx的规范,需要在bitop中建立一个bit.h文件,内容如下:

#ifndef __LUA_BITOP_H_
#define __LUA_BITOP_H_

#if __cplusplus
extern "C" {
#endif

#include "lauxlib.h"

LUALIB_API int luaopen_bit(lua_State *L);

#if __cplusplus
}
#endif

#endif

在lpeg中建立一个lpeg.h文件,内容如下:

#ifndef __LUA_LPEG_H_
#define __LUA_LPEG_H_

#if __cplusplus
extern "C" {
#endif

#include "lpeg/lptypes.h"
#include "lpeg/lpcap.h"
#include "lpeg/lpcode.h"
#include "lpeg/lpprint.h"
#include "lpeg/lptree.h"
#include "lpeg/lpvm.h"

int luaopen_lpeg(lua_State *L);
  

#if __cplusplus
}
#endif

#endif

在sproto中建立一个lsproto.h文件,内容如下:

#ifndef __LUA_LSPROTO_H_
#define __LUA_LSPROTO_H_

#if __cplusplus
extern "C" {
#endif

#include "lauxlib.h"

int luaopen_sproto_core(lua_State *L);

#if __cplusplus
}
#endif

#endif

在lpack中建立一个lpack.h文件,内容如下:

#ifndef __LUA_LPACK_H_
#define __LUA_LPACK_H_
#if __cplusplus
extern "C" {
#endif

#include "lauxlib.h"

int luaopen_pack(lua_State *L);

#if __cplusplus
}
#endif
#endif

在cocos2d-x/cocos/scripting/lua-bindings/manual/network目录下,找到 lua_extensions.c 文件。在头部包含所需文件。

#include "sproto/lsproto.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
#include "bitop/bit.h"
#endif
#include "lpeg/lpeg.h"
#include "lpack/lpack.h"

在luax_exts内,加入下列几行。

  { "sproto.core", luaopen_sproto_core },
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
  { "bit", luaopen_bit },
#endif
  { "lpeg", luaopen_lpeg },
  { "string", luaopen_pack },

Android支持

在cocos2d-x/cocos/scripting/lua-bindings/proj.android目录下,打开 Android.mk 文件,在那一长串加载c文件后面,加入我们需要的c文件

      ../../../../external/lua/lpeg/lpcap.c \
      ../../../../external/lua/lpeg/lpcode.c \
      ../../../../external/lua/lpeg/lpprint.c \
      ../../../../external/lua/lpeg/lptree.c \
      ../../../../external/lua/lpeg/lpvm.c \
      ../../../../external/lua/sproto/lsproto.c \
      ../../../../external/lua/sproto/sproto.c \
      ../../../../external/lua/lpack/lpack.c 

Android支持luajit库,里面已经包含了bit库,所以不用加bit.c了,不然编译的时候会出现多重定义的错误。

总得来说还是很简单的,只需三步: 文件放到cocos2d-x/external/lua目录下 修改lua_extensions.c,包含相关文件 修改Android.mk做Android支持

https://github.com/dot123/cocos2d-lua-sproto.git

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].