尝试优化游戏时的touchmove事件代码

This commit is contained in:
MrZ626
2020-12-26 16:23:43 +08:00
parent 30042a363e
commit e9b4e4450c

View File

@@ -81,18 +81,21 @@ function scene.touchUp(_,x,y)
end end
function scene.touchMove() function scene.touchMove()
if noTouch then return end if noTouch then return end
local L=tc.getTouches()
local l=tc.getTouches() for i=#L,1,-1 do
L[2*i-1],L[2*i]=SCR.xOy:inverseTransformPoint(tc.getPosition(L[i]))
end
for n=1,#VK do for n=1,#VK do
local B=VK[n] local B=VK[n]
for i=1,#l do if B.ava then
local x,y=SCR.xOy:inverseTransformPoint(tc.getPosition(l[i])) for i=1,#L,2 do
if(x-B.x)^2+(y-B.y)^2<=B.r^2 then if(L[i]-B.x)^2+(L[i+1]-B.y)^2<=B.r^2 then
goto next goto continue
end
end end
PLAYERS[1]:releaseKey(n)
end end
PLAYERS[1]:releaseKey(n) ::continue::
::next::
end end
end end
function scene.keyDown(key) function scene.keyDown(key)