How do I make joysticks controls

Please help

@Amrothecoder Touch anywhere on the screen then move your finger relative to the dot in the circle. You can lift your finger and touch anywhere to create another control.


displayMode(FULLSCREEN)

function setup()
    x,y=0,0
    sx=WIDTH/2
    sy=HEIGHT/2
end

function draw()
    background(40, 40, 50)
    fill(255)
    sprite("Planet Cute:Character Boy",sx,sy)
    if x+y>0 then
        sx=sx+(tx-x)/10
        sy=sy+(ty-y)/10
        fill(255)
        ellipse(x,y,10)    -- draw circle center
        noFill()
        stroke(255)
        strokeWidth(4)
        ellipse(x,y,200)    -- draw outer circle
    end
end

function touched(t)
    if t.state==BEGAN then    -- starting center point
        x=t.x
        y=t.y
        tx=x
        ty=y
    elseif t.state==MOVING then
        tx=t.x
        ty=t.y
    elseif  t.state==ENDED then    -- done moving
        x,y=0,0
    end
end

@Nat’s controllers

Search the forums for a set of code called Controllers. There was a library of controllers that was posted a long time ago.