Hi
I have a question on the touch. I would like to know how to make a scrolling of sprite with the touch, a little as a Web site. You can help me please?
@goodboy2004 Here’s about as simple as it gets moving a Sprite with the function touched.
function setup()
sx,sy=WIDTH/2,HEIGHT/2
end
function draw()
background(40, 40, 50)
sprite("Planet Cute:Character Boy",sx,sy)
end
function touched(t)
if t.state==MOVING then
sx=t.x
sy=t.y
end
end
@goodboy2004 Here’s another version. Slide your finger right/left/up/down not on the Sprite to move it.
function setup()
dx,dy=0,0
sx,sy=WIDTH/2,HEIGHT/2
end
function draw()
background(40, 40, 50)
sprite("Planet Cute:Character Boy",sx+dx,sy+dy)
end
function touched(t)
if t.state==MOVING then
dx=dx+t.deltaX
dy=dy+t.deltaY
end
end
Thanks