在得到下一个台子的中点,以及当前小人脚的中点后,就可以得到两个点之间的距离 D ,这个距离 D 控制按压时间。
按压时间 t 与相应的跳跃的距离 d 的关系是线性的,也就是说 d = a * t,所以通过不断调整a,总能找到最合适的a的值a_best。
所以 t = D / a_best
接下来就是模拟触屏 t 时间长度。
通过向IP地址为 IP = sessionIP + "/session/" + sessionId + /wda/touchAndHold POST一个按压时间duration的命令即可。
例如,在终端你可以敲入下列命令来进行10s时间的触屏
curl -X POST -H "Content-Type: application/json" \-d "{\"duration\": 10.0} http://169.254.250.62:8100/session/8A0DCDC3-4839-4A8B-8B7C-C0DEB74D3988/wda/touchAndHold
用swift实现:
@objc func postToJump() {
let urlPath = self.ip + "session/" +self.sessionID +"/wda/touchAndHold"
let parameters:NSMutableDictionary = NSMutableDictionary.init()