摘要: 1 package org.cocos2dx.lib; 2 3 public class Cocos2dxLuaJavaBridge 4 { 5 public static native int callLuaFunctionWithString(int luaFunctionId, String value); 6 public static native int callL... 阅读全文
posted @ 2017-09-20 15:13 淡墨&青衫 阅读(598) 评论(0) 推荐(0) 编辑
摘要: 打开如图位置的luaj.lua文件 再观察 LuaJavaBridge.h 文件开头的地方 可以发现LuaJavaBridge.cpp也是一层中间代码,负责把lua和java粘合起来 注:在c里面调用了lua.h头文件即可用C调用LUA。后续继续写JAVA调用LUA以及LUA与C++之间的互调 阅读全文
posted @ 2017-09-20 14:47 淡墨&青衫 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 1 --元表 对2个table进行操作,允许我们改变table的行为,每个行为关联了对应的元方法 2 3 mytable={} --普通表 4 mymetatable={} --元表 5 6 --mymetatable 设为mytable的元表 7 setmetatable(mytable,mymetatable) 8 --返回元表 9 t=getmetatable(myt... 阅读全文
posted @ 2017-09-20 14:46 淡墨&青衫 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 1 --模块与包 2 3 -- 定义一个名为 module 的模块 4 module={} 5 6 module.consta="这是一个常量" 7 8 function module.func1() 9 io.write("func1共有函数\n") 10 end 11 12 local function func2() 13 io.write("func2私有函数\... 阅读全文
posted @ 2017-09-20 14:45 淡墨&青衫 阅读(695) 评论(0) 推荐(0) 编辑
摘要: 1 --table 2 3 mytable={} 4 5 mytable[1]="lua" 6 7 --打印table名称即是地址,和数组一样 8 print(mytable) 9 10 --打印数组名称即是地址 11 myarray={"xx","oo"} 12 print(myarray) 13 14 ---比较:数组就是下标为数字的,table下标可为数字,可为... 阅读全文
posted @ 2017-09-20 14:44 淡墨&青衫 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1 --函数 2 function max(num1,num2) 3 if(num1>num2) then 4 result=num1 5 else 6 result=num2 7 end 8 return result 9 end 10 11 --print("max(1,150)",max(1,150)) 12 13 14 --Lua 中我们可以将函数作为参数传递给函... 阅读全文
posted @ 2017-09-20 14:43 淡墨&青衫 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 打开如图位置的luaj.lua文件 再观察 LuaJavaBridge.h 文件开头的地方 可以发现LuaJavaBridge.cpp也是一层中间代码,负责把lua和java粘合起来 注:在c里面调用了lua.h头文件即可用C调用LUA。后续继续写JAVA调用LUA以及LUA与C++之间的互调 阅读全文
posted @ 2017-09-20 14:28 淡墨&青衫 阅读(741) 评论(0) 推荐(0) 编辑