touching变量移入SCN模块

修复iOS上经常卡掉第一个触摸导致后续不能和控件交互
This commit is contained in:
MrZ626
2021-10-18 23:45:03 +08:00
parent ed2b07d5cf
commit 013765d5d2
2 changed files with 6 additions and 5 deletions

View File

@@ -71,7 +71,6 @@ local xOy=SCR.xOy
local ITP=xOy.inverseTransformPoint local ITP=xOy.inverseTransformPoint
local mx,my,mouseShow=-20,-20,false local mx,my,mouseShow=-20,-20,false
local touching--First touching ID(userdata)
joysticks={} joysticks={}
local devMode local devMode
@@ -181,8 +180,8 @@ end
function love.touchpressed(id,x,y) function love.touchpressed(id,x,y)
mouseShow=false mouseShow=false
if SCN.swapping then return end if SCN.swapping then return end
if not touching then if not SCN.mainTouchID then
touching=id SCN.mainTouchID=id
WIDGET.unFocus(true) WIDGET.unFocus(true)
love.touchmoved(id,x,y,0,0) love.touchmoved(id,x,y,0,0)
end end
@@ -201,12 +200,12 @@ end
function love.touchreleased(id,x,y) function love.touchreleased(id,x,y)
if SCN.swapping then return end if SCN.swapping then return end
x,y=ITP(xOy,x,y) x,y=ITP(xOy,x,y)
if id==touching then if id==SCN.mainTouchID then
WIDGET.press(x,y,1) WIDGET.press(x,y,1)
WIDGET.release(x,y) WIDGET.release(x,y)
WIDGET.cursorMove(x,y) WIDGET.cursorMove(x,y)
WIDGET.unFocus() WIDGET.unFocus()
touching=false SCN.mainTouchID=false
end end
if SCN.touchUp then SCN.touchUp(x,y)end if SCN.touchUp then SCN.touchUp(x,y)end
if(x-lastX)^2+(y-lastY)^2<62 then if(x-lastX)^2+(y-lastY)^2<62 then

View File

@@ -4,6 +4,7 @@ local abs=math.abs
local scenes={} local scenes={}
local SCN={ local SCN={
mainTouchID=nil, --First touching ID(userdata)
cur='NULL', --Current scene name cur='NULL', --Current scene name
swapping=false, --If Swapping swapping=false, --If Swapping
stat={ stat={
@@ -52,6 +53,7 @@ function SCN.swapUpdate(dt)
if S.time<S.changeTime and S.time+dt>=S.changeTime then if S.time<S.changeTime and S.time+dt>=S.changeTime then
--Scene swapped this frame --Scene swapped this frame
SCN.init(S.tar,SCN.cur) SCN.init(S.tar,SCN.cur)
SCN.mainTouchID=nil
end end
if S.time<0 then if S.time<0 then
SCN.swapping=false SCN.swapping=false