马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[Lua] 纯文本查看 复制代码 --节点查找,返回bounds()
function 节点查找(target_sel, target_sleep)
target_sleep = target_sleep or 5
local node = target_sel:findOne(target_sleep * 1000)
if node~= nil then
return node: bounds()
else
return nil
end
end
----节点查找,返回是否点击
function 节点点击(target_sel, target_sleep)
target_sleep = target_sleep or 5
local node = target_sel:findOne(target_sleep * 1000)
if node~= nil then
local l,t,r,b = node:bounds()
if l>0 and t>0 and r>0 and b>0 then
local wr = math.floor((r - l)*0.1)
local hr = math.floor((b - t)*0.1)
tap(math.random(l+wr,r-wr),math.random(t+hr,b-hr))
return true
else
return false
end
else
return false
end
end
--点击目标,返回是否完成
function 节点点击等待(target_sel, wait_sel, target_sleep, wait_sleep)
target_sleep = target_sleep or 5
wait_sleep = wait_sleep or 5
local result = ""
for n1=1,3 do
local node1 = target_sel:findOne(target_sleep * 1000)
if node1~= nil then
result = "找到目标"
for n2=1,3 do
local l,t,r,b = node1:bounds()
if l>0 and t>0 and r>0 and b>0 then
result = "目标在可视区域,点触目标中心位置"
local wr = math.floor((r - l)*0.1)
local hr = math.floor((b - t)*0.1)
tap(math.random(l+wr,r-wr),math.random(t+hr,b-hr))
sleep(500)
local node2 = wait_sel:findOne(wait_sleep * 1000)
if node2~= nil then
result = "目标2出现,操作完成"
--目标2出现,跳出n2循环
break
else
result = "目标2未出现,操作失败"
end
else
result = "目标["..tostring(l)..", "..tostring(t)..", "..tostring(r)..", "..tostring(b).."]不可视,操作失败"
break
end
end
--跳出n1循环
break
else
result = "目标1未找到,操作失败"
end
end
end
|