修正uttt小程序触屏不响应

This commit is contained in:
MrZ626
2021-10-26 11:26:12 +08:00
parent 62c802d2c3
commit 9c40f4918c

View File

@@ -100,6 +100,34 @@ function scene.sceneInit()
BG.set('rainbow')
end
function scene.mouseMove(x,y)
x,y=int((x-280)/80),int(y/80)
curX,curx=int(x/3)+int(y/3)*3+1,x%3+y%3*3+1
if
x<0 or x>8 or
y<0 or y>8 or
curX<1 or curX>9 or
curx<1 or curx>9 or
score[curX]or
not(target==curX or not target)or
board[curX][curx]or
gameover
then
curX,curx=nil
end
end
function scene.mouseDown(x,y)
scene.mouseMove(x,y)
if curX then
place(curX,curx)
end
end
scene.touchDown=scene.mouseMove
scene.touchMove=scene.mouseMove
scene.touchUp=scene.mouseDown
function scene.draw()
gc.push('transform')
--origin pos:0,140; scale:4
@@ -201,33 +229,6 @@ function scene.draw()
end
end
end
scene.touchDown=scene.mouseMove
scene.touchMove=scene.mouseMove
scene.touchUp=scene.mouseDown
function scene.mouseMove(x,y)
x,y=int((x-280)/80),int(y/80)
curX,curx=int(x/3)+int(y/3)*3+1,x%3+y%3*3+1
if
x<0 or x>8 or
y<0 or y>8 or
curX<1 or curX>9 or
curx<1 or curx>9 or
score[curX]or
not(target==curX or not target)or
board[curX][curx]or
gameover
then
curX,curx=nil
end
end
function scene.mouseDown(x,y)
scene.mouseMove(x,y)
if curX then
place(curX,curx)
end
end
scene.widgetList={
WIDGET.newButton{name="reset",x=1140,y=540,w=170,h=80,font=40,color='lG',code=restart},