Application installation of PROTUBUF in COCOS2DX

Source: Internet
Author: User

Place Protubuf in the external folder

A new filter Protubuf is added to the luacocos2d in the VS project to add PB.C to the filter.

Compile the Pb.c file's properties into a C file.

Place the luastruct under the external LUA

A new filter Luastruc is added to the luacocos2d in the VS project to add struct.c to the filter.

Compile the Struct.c file's properties into a C file.

Then register in the Lua_module_rigister.cpp. Add the following code

#ifdef __cplusplus
extern "C" {
#endif
int Luaopen_protobuf_c (lua_state *l);
Intluaopen_struct (lua_state* L);
#ifdef __cplusplus
}
#endif

Add in the Lua_module_register function

Luaopen_protobuf_c (L);
Luaopen_struct (L);

At this point Protubuf can be run on Windows. But not on Android.

Modify the Android.mk file under Frameworks\cocos2d-x\cocos\scripting\lua-bindings\proj.android

#network
Local_src_files + =. /.. /.. /.. /external/protobuf/pb.c
#luastruct
Local_src_files + =. /.. /.. /.. /external/lua/luastruct/struct.c

This andriod can also be run.

For use in Lua, you still need to

Lua code to add protubuf under the LUA Engineering directory.

This protubuf can be used in Lua.

But if applied to the actual combat, still need to use Luasocket or WebSocket first read the packet, and then use Protubuf parse out the actual data.

Application installation of PROTUBUF in COCOS2DX

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.