forked from chudongjingling/open_code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0caf95e
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--该函数来自于 QQ 群 592860666,由开发者“一个人自嘲”分享 | ||
Direction = {left=0,right=1,up=2,down=3} | ||
|
||
function slide(x1,y1,dist,dir,ms,step) | ||
ms = ms or 100 | ||
step = step or 30 | ||
local x2,y2 | ||
if dir == Direction.up then | ||
moveTo(x1,y1, x1, y1-dist,{["step"] = step,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo(x1, y1-dist, x1, y1-dist+1,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo(x1, y1-dist+1, x1, y1-dist+2,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
elseif dir == Direction.down then | ||
moveTo(x1,y1, x1, y1+dist,{["step"] = step,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo(x1, y1+dist, x1, y1+dist-1,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo(x1, y1+dist-1, x1, y1+dist-2,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
elseif dir == Direction.left then | ||
moveTo(x1,y1, x1-dist, y1,{["step"] = step,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo(x1, y1, x1-dist+1, y1,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo( x1-dist+1, y1, x1-dist+2, y1,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
elseif dir == Direction.right then | ||
moveTo(x1,y1, x1+dist, y1,{["step"] = step,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo(x1, y1, x1+dist-1, y1,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
mSleep(ms) | ||
moveTo( x1+dist-1, y1, x1+dist-2, y1,{["step"] = 1,["ms"] = 50,["index"] = 1,["stop"] = false}) | ||
else | ||
nLog('滑动方向错误,必须为上下左右中的一个') | ||
end | ||
mSleep(500) | ||
end |