Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Can I move the circle by touch?

edited July 2016 in Questions Posts: 4
-- Art

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(0, 85, 255, 255)

    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here
    ellipse(WIDTH/2, HEIGHT/2, 100)

    -- This sets the outline color
    stroke(26, 236, 239, 255)

    -- This sets the ellipse color
    fill(4, 237, 241, 255)

end

This is the final result for a drawing tutorial I did on Bitbucket.org after clicking the button on the lower right side of the Codea main menu. Is it possible to move the circle around by touching it? I clicked the eye symbol on the keyboard that led me to the sound, touch, shaders, etc list. If I can move the circle, do I use some of the suggested lines of code for Touch, all of them, or something else?

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,470

    @VersatileAlien Here's an example of moving a circle using touch.

    function setup()
        x=WIDTH/2
        y=HEIGHT/2
    end
    
    function draw()
        background(0)  
        fill(255)       
        ellipse(x,y,100)
    end
    
    function touched(t)
        if t.state==MOVING then
            x=t.x
            y=t.y
        end   
    end
    
Sign In or Register to comment.