This commit is contained in:
parent
33aa10a593
commit
bbd35f667b
2 changed files with 18 additions and 8 deletions
|
@ -360,7 +360,8 @@ class MuMu12IPC:
|
|||
interval (float): 滑动完成后的等待时间,单位为秒,默认 0
|
||||
func (Callable[[np.ndarray], Any]): 截图后处理的函数,默认空函数
|
||||
"""
|
||||
frame_time = 1 / 120
|
||||
frame_rate = 120
|
||||
frame_time = 1 / frame_rate
|
||||
start_time = time.perf_counter()
|
||||
|
||||
if fall:
|
||||
|
@ -372,11 +373,15 @@ class MuMu12IPC:
|
|||
|
||||
trajectory = HumanizeMouseTrajectory(
|
||||
(x0, y0), (x1, y1), duration
|
||||
).generate_curve(frame_time)
|
||||
).generate_curve(frame_rate)
|
||||
|
||||
for point in trajectory[1:]:
|
||||
start_time = time.perf_counter()
|
||||
for i, point in enumerate(trajectory[1:], 1):
|
||||
target_time = start_time + i * frame_time
|
||||
self.touch_down(point[0], point[1])
|
||||
time.sleep(frame_time)
|
||||
now = time.perf_counter()
|
||||
if now < target_time:
|
||||
time.sleep(target_time - now)
|
||||
|
||||
if lift:
|
||||
self.touch_up()
|
||||
|
|
|
@ -221,7 +221,8 @@ class Client:
|
|||
interval (float, optional): 拖动后的等待时间. Defaults to 0.
|
||||
func (Callable[[tp.Image], Any], optional): 处理截图的函数. Defaults to lambda _: None.
|
||||
"""
|
||||
frame_time = 1 / 120
|
||||
frame_rate = 120
|
||||
frame_time = 1 / frame_rate
|
||||
start_time = time.perf_counter()
|
||||
|
||||
if fall:
|
||||
|
@ -233,11 +234,15 @@ class Client:
|
|||
|
||||
trajectory = HumanizeMouseTrajectory(
|
||||
(x0, y0), (x1, y1), duration
|
||||
).generate_curve(frame_time)
|
||||
).generate_curve(frame_rate)
|
||||
|
||||
for point in trajectory[1:]:
|
||||
start_time = time.perf_counter()
|
||||
for i, point in enumerate(trajectory[1:], 1):
|
||||
target_time = start_time + i * frame_time
|
||||
self.control.touch(point[0], point[1], const.ACTION_MOVE)
|
||||
time.sleep(frame_time)
|
||||
now = time.perf_counter()
|
||||
if now < target_time:
|
||||
time.sleep(target_time - now)
|
||||
|
||||
if lift:
|
||||
self.control.touch(x1, y1, const.ACTION_UP)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue