From 9c40f4918cd039c6810c569c7b14d4e79a3784d6 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 26 Oct 2021 11:26:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3uttt=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=A7=A6=E5=B1=8F=E4=B8=8D=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_UTTT.lua | 55 ++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/parts/scenes/app_UTTT.lua b/parts/scenes/app_UTTT.lua index 11adfe2d..04f73c21 100644 --- a/parts/scenes/app_UTTT.lua +++ b/parts/scenes/app_UTTT.lua @@ -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},