工作原理电脑:Windows 或 Mac
软件:Lua 编辑器、抓色器(可以在 官网 下载)
手机:触动精灵(iOS 或者安卓都可以)
抓色器远程连接手机截图,找到坐标点和颜色值,作业部落上有使用教程。( https://www.zybuluo.com/miniknife/note/629913 )。
通过 Lua 实现模拟点击
网上分享的帖子不管是 python 还是其他语言基本都是安卓平台的,其实 iOS 也可以用 Lua 模拟点击实现跳一跳自动辅助。
前提是你的 iPhone 越狱了。
步骤:
代码:
- local screenWidth, screenHeight= getScreenSize();--获取屏幕分辨率
- local distanceTimeRate = 1.15--按压时间与距离的系数,数字越大表示蓄力时间越长,当前为 6P 的系数local
- local targetPositionOffset = screenHeight * 0.012--表示方块最上方的点,距离中心点的偏移
- function Touch(x, y, millsSecond)
- touchDown(x, y)
- mSleep(millsSecond)
- touchUp(x, y)
- end
- function main()
- -- dialog("请在3秒内打开游戏,并点击开始按钮", 0);
- mSleep(1000)
- DoLoop()
- end
- function DoLoop()
- while true do
- keepScreen(true);
- if DoJump() == false then
- keepScreen(false);
- break
- end
- keepScreen(false);
- mSleep(2000)
- end
- end
- function DoJump()
- local x, y = GetCalcSelfPosition()
- if x == -1 or x == 0 then
- return false
- end
- local endX = screenWidth-3 -- 1080 1920
- local endY = screenHeight * 0.7
- local startX = 0
- local startY = screenHeight * 0.2
- if x < screenWidth / 2 then
- startX = screenWidth / 2
- else
- endX = screenWidth / 2
- end
- local targetX, targetY = GetTargetPosition(startX, startY, endX, endY)
- local distance = math.sqrt( (x - targetX) * (x - targetX) + (y - targetY) * (y - targetY) )
- local pressTime = CalcHoldTime(distance)
- Touch(100,100, pressTime)
- return true
- end
- function GetCalcSelfPosition()
- x,y = findMultiColorInRegionFuzzy( 0x373860, "-2|-214|0x34353d,-42|-2|0x2b2b49,40|-4|0x393550", 98, 0, 0, screenWidth, screenHeight) -- 6p
- -- x,y = findMultiColorInRegionFuzzy( 0x38365e, "-16|-6|0x35335a,13|-5|0x39375f", 98, 0, 0, screenWidth, screenHeight)
- return x, y
- end
- function GetTargetPosition(startX, startY, endX, endY)
- local step = 3
- local r, g, b, rr, gg, bb
- for y = startY , endY, step do
- r, g, b = getColorRGB(1, y)
- for x = startX, endX , step do
- rr, gg, bb = getColorRGB(x, y)
- if isColor(r, g, b, rr, gg, bb, 98) then
- r = rr
- g = gg
- b = bb
- else
- return x, y + targetPositionOffset
- end
- end
- end
- return -1, -1
- end
- function isColor(rr, gg, bb, r, g, b ,s)
- local fl,abs = math.floor,math.abs
- s = fl(0xff*(100-s)*0.01)
- if abs(r-rr)<s and abs(g-gg)<s and abs(b-bb)<s then
- return true
- end
- return false
- end
- function CalcHoldTime(distance)
- return distance * distanceTimeRate
- end
- main()
如果脚本跑的并不准确,可以修改参数
distanceTimeRate: 数字越大表示蓄力时间越长
targetPositionOffset: 表示方块最上方的点,距离中心点的偏移
如果还是不行的话,那就算了吧...
思路本文源码和原理参考自知乎 xtutu
来源: http://www.jianshu.com/p/4e46fbab5b06