真机调试遇到的问题,Luajavabridge相关,求助
答案:1 悬赏:10 手机版
解决时间 2021-02-15 13:28
- 提问者网友:富士山上尢
- 2021-02-14 15:19
真机调试遇到的问题,Luajavabridge相关,求助
最佳答案
- 五星知识达人网友:長槍戰八方
- 2021-02-14 16:46
package com.benny.game.luajavabridgedemo;
import org.cocos2dx.lib.Cocos2dxActivity;
import android.os.Bundle;
public class Luajavabridgedemo extends Cocos2dxActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
static {
System.loadLibrary("game");
}
static public int addTowNumber(final int number1,final int number2)
{
return number1+number2;
}
}
--------------------------lua------------------------
function MainScene:ctor()
local __item = ui.newTTFLabelMenuItem({
text = "this is luajavabridge test",
size = 32,
x = display.cx,
y = display.cy,
align = ui.TEXT_ALIGN_CENTER,
listener = function()
if device.platform ~= "android" then
print("please run this on android device")
return
end
self:luajTest()
end
})
self:addChild(ui.newMenu({__item}))
end
function MainScene:luajTest()
local __javaClassName = "com/benny/game/Luajavabridgedemo"
local __javaMethodName = "addTowNumber"
local __javaParams = {1,2}
-- local __javaMethodSig = "(II)I"
luaj.callStaticMethod(__javaClassName, __javaMethodName, __javaParams)
end
local __javaClassName = "com/benny/game/luajavabridgedemo/Luajavabridgedemo"
你这个写错了 写掉一个目录
import org.cocos2dx.lib.Cocos2dxActivity;
import android.os.Bundle;
public class Luajavabridgedemo extends Cocos2dxActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
static {
System.loadLibrary("game");
}
static public int addTowNumber(final int number1,final int number2)
{
return number1+number2;
}
}
--------------------------lua------------------------
function MainScene:ctor()
local __item = ui.newTTFLabelMenuItem({
text = "this is luajavabridge test",
size = 32,
x = display.cx,
y = display.cy,
align = ui.TEXT_ALIGN_CENTER,
listener = function()
if device.platform ~= "android" then
print("please run this on android device")
return
end
self:luajTest()
end
})
self:addChild(ui.newMenu({__item}))
end
function MainScene:luajTest()
local __javaClassName = "com/benny/game/Luajavabridgedemo"
local __javaMethodName = "addTowNumber"
local __javaParams = {1,2}
-- local __javaMethodSig = "(II)I"
luaj.callStaticMethod(__javaClassName, __javaMethodName, __javaParams)
end
local __javaClassName = "com/benny/game/luajavabridgedemo/Luajavabridgedemo"
你这个写错了 写掉一个目录
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯