大佬教程收集整理的这篇文章主要介绍了怎样使用Cocos LUACompile,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
将.lua
文件编译为.luac
所涉及到的加密方法
如果是cocos2d-x V3.3 或者更高级的版本,你需要配置cocos consol
(请查看https://github.com/cocos2d/cocos2d-x/blob/v3/README.md)
如果版本是cocos2d-x V2.2.6,你应该安装Python
,然后设置Python的环境变量.
如果是cocos2d-x V3.3 或者更高级的版本,在终端里输入cocos luacompile [arguments]
如果版本是cocos2d-x V2.2.6,在终端里,首先cd
进目录tools/cocos2d-console/console
,然后输入./cocos2d.py luacompile [arguments]
.
参数 | 参数的值 | 例子 | 描述 | 是否必须 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-h,--Help | - | Show the Help message and exit | no | ||||||||||||
-v,--verbose | verbose output | -s,--src | source directory | ./projects/MyLuaGame/src |
Specify source directory of lua files needed to be compiled,support mutiple source directory | yes | |||||||||
-d,--dst | desTination directory | ./projects/MyLuaGame/dst | Specify desTination directory which bytecode files to be stored. | -e,--encrypt | bool | True | Whether or not to encrypt lua files. | -k,--encryptkey | any String | @H_203_116@myLuaKey Specify the encrypt key for encrypTing lua scripts. It's only take effect when-e,--encrypt is enabled. Default value is2dxLua . |
-b,--encryptsign | @H_203_116@myLuaSign Specify the encrypt sign for encrypTing lua scripts. It's only take effect when--encrypt is enabled. Default value isXXTEA . |
--disable-compile | Whether or not to compile lua scripts | no |
使用luacompile时,有以下几种方式
cocos2d-x 版本 | 描述 | ||||
---|---|---|---|---|---|
cocos luacompile -h | cocos2d-x V3.3 or higher version | Show the Help message | |||
cocos luacompile -s src_dir -d dst_dir | Precompile the Lua files in thesrc_dir directory to bytecode files whichluajit supports,then store them in the dst_dir directory by the same directory structure. |
||||
cocos luacompile -s src_dir -d dst_dir -e True | :4px; border:1px solid rgb(187,then encrypt this bytecoed files byxxtea .Thekey andsign for encrypTing are2dxLua andXXTEA by default. By adding-k xxx -b xxx' to the command,developers can change the keyand sign, -k xxxset the key value and -b xxx` set the sign value. The encrypted files are stored in the dst_dir directory by the same directory structure. |
||||
cocos luacompile -s src_dir -d dst_dir -e True --disable-compile True | Encrypt the Lua files in thesrc_dir byxxtea ,then store them in the dst_dir directory by the same directory structure. Theset the key value and -b xxx` set the sign value. This command is mainly used to make a set of encrypted files run both 32bit and 64bit iOS devices at the same time. Because Apple demand new app must support 64bit,but the stable luajit doesn't support the arm64bit,so providing this command to encrypt the lua files directly. |
||||
./cocos2d.py luacompile -h | cocos2d-x V2.2.6 | ./cocos2d.py luacompile -s src_dir -d dst_dir | ./cocos2d.py luacompile -s src_dir -d dst_dir -e True | xxtea.TThe ./cocos2d.py luacompile -s src_dir -d dst_dir -e True --disable-compile True |
XXTEAby default,by addingset the key value and -b xxx` set the sign value. This command is mainly used to make a set of encrypted files run both 32bit and 64bit iOS devices at the same time. |
注意: 如果在游戏里使用了xxtea加密,你必须调用在c++代码里,调用LuaStack里的setXXTEAKeyAndSign方法以设置key和sign来解密文件。
以上是大佬教程为你收集整理的怎样使用Cocos LUACompile全部内容,希望文章能够帮你解决怎样使用Cocos LUACompile所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。