Hi. I’ve been making a game sorta thing, but I can’t seem to draw a circle where the touch.x and touch.y are. This is what I was using:
function touched(touch)
fill(255)
ellipse(touch.x,touch.y,100)
end
Hi. I’ve been making a game sorta thing, but I can’t seem to draw a circle where the touch.x and touch.y are. This is what I was using:
function touched(touch)
fill(255)
ellipse(touch.x,touch.y,100)
end
@Kolosso Here’s something to get you started.
function setup()
x,y=0,0
end
function draw()
background(40, 40, 50)
fill(255)
ellipse(x,y,90)
text("drag your finger around the screen",WIDTH/2,HEIGHT/2)
end
function touched(t)
if t.state==BEGAN or t.state==MOVING then
x=t.x
y=t.y
end
end
Thanks. makes plenty of sense but, i kinda figured it out on my own before i read this
You could also do
function draw()
background(255, 255, 255, 255)
fill(0, 0, 0, 255)
ellipse(CurrentTouch.x, CurrentTouch.y, 200)
text("Touch the screen to move the ball!", WIDTH/2, HEIGHT-50)
end
But since CurrentTouch is barely used, dave’s code is probably better, mine is just shorter
I think your own code does not work because the touch function is executed before draw function, whichs background() function simply clears your screen all over just after your circle is drawn.
Or not. That’s just how I’d explain the problem
I think i get it now. thanks everyone. I’m kinda new to codea talk so how do i delete this discussion?
oh. I didn’t know that
function draw()
if CurrentTouch.state ~= ENDED then
ellipse(CurrentTouch.x,CurrentTouch.y,100)
end
end
How’s this?
EDIT: fixed formet