Hi, I’m new to lua and all this coding business and starting to learn via Codea.
Just a quick question, I am trying to create a cursor that follows your finger when you touch the screen, and when you remove your finger the cursor disappears.
So far this is my code, it is simple but Im not sure how to get the image to go after the touch ha been removed.
function touch()
if touch.state == ENDED then touching = false
else touching = true
end
end
function setup()
end
function draw()
background(0, 0, 0, 255)
fill(127, 122, 132, 255)
ellipse( CurrentTouch.x, CurrentTouch.y, 15)
if touching == true then draw = ellipse( CurrentTouch.x, CurrentTouch.y, 15)
end
end
function setup()
cursorPosition = nil
cursorActive = false
end
function touched(touch)
if touch.state == BEGAN or touch.state == MOVING then
cursorPosition = vec2(x,y)
cursorActive = true
elseif touch.state == ENDED then
cursorPosition = nil
cursorActive = false
end
end
function draw()
background(0,0,0,255)
fill(127.122,132,255)
if cursorActive == true then
ellipse(cursorPosition.x,cursorPosition.y,15)
end
end
-- Use this function to perform your initial setup
function setup()
displayMode(FULLSCREEN)
cursorsize = 15
x = 200
y = 570
end
-- This function gets called once every frame
function draw()
background(0, 0, 0, 255)
fill(127, 122, 132, 255)
-- This sets the line thickness
--strokeWidth(thickness)
ellipse(x,y, cursorsize)
if CurrentTouch.state == BEGAN or CurrentTouch.state == MOVING then
x = CurrentTouch.x
y = CurrentTouch.y
cursorsize =15
else
cursorsize =0
end
-- Do your drawing here
end
@skullagepk, Sorry I didn’t notice that, and Please don’t ad things to ild discussion unless you MUST ask something, and in which case you should PM the person, not bump the thread.
@TheRogueBatcher, forum mods don’t have time to close every single topic, and it isn’t nescessary, please don’t bring this topic back up the main page by posting comments like this please