So I am (was) making for the game competition. I have hit a roadblock. I am not good enough with lua to find my error so I need help, I realize this also probably cancels this project for the competition, for everyone sees what it is, but oh we’ll. The issue is with currentTouch.state. I am trying to get a specific checker to move when I drag it and then when I click another, have it not instantly zoom to the old currentTouch.
r1x=95
r1y=95
r2x=175
r2y=95
r3x=255
r3y=95
r4x=335
r4y=95
function draw()
touch()
background(0, 0, 0, 255)
fill(255, 255, 255, 255)
--the game board
rect(55,55,80,80)
rect(215,55,80,80)
rect(375,55,80,80)
rect(535,55,80,80)
rect(135,135,80,80)
rect(295,135,80,80)
rect(455,135,80,80)
rect(615,135,80,80)
rect(55,215,80,80)
rect(215,215,80,80)
rect(375,215,80,80)
rect(535,215,80,80)
rect(135,295,80,80)
rect(295,295,80,80)
rect(455,295,80,80)
rect(615,295,80,80)
rect(55,375,80,80)
rect(215,375,80,80)
rect(375,375,80,80)
rect(535,375,80,80)
rect(135,455,80,80)
rect(295,455,80,80)
rect(455,455,80,80)
rect(615,455,80,80)
rect(55,535,80,80)
rect(215,535,80,80)
rect(375,535,80,80)
rect(535,535,80,80)
rect(135,615,80,80)
rect(295,615,80,80)
rect(455,615,80,80)
rect(615,615,80,80)
-- the checker pieces
touch()
fill(255, 0, 0, 255)
ellipse(r1x,r1y,50,50)
end
function touch()
x=CurrentTouch.x
y=CurrentTouch.y
if CurrentTouch.state==BEGAN then
if x>r1x-25 and x<r1x+25 and y>r1y-25 and y<r1y+25 then
r1x=CurrentTouch.x
r1y=CurrentTouch.y
end
if CurrentTouch.state==ENDED then
x=nil
y=nil
end
end
end
Thanks for the help! (sorry if the code comes up without enters, that seems to happen a lot with it.)