Stationary Touches

Can someone explain how stationary touches work? Can it keep track whether or not a moving touch stopped because thats what I’m trying to use it for?

Could you explain a little bit more what you want to do? Because touch.state == ENDED tells you when your touch ended, but it is not what you mean?

Wouldn’t a stationary touch have its prevX and prevY the same as it’s x and y? Edit: also use deltaX and deltaY

@Coder and @Jmv38. With touch.state==ENDED, the object that the user picks up will continue to remain picked up, but I just want to make it so if the user stops moving the object will automatically release (its actually really helpful in my game that I do this haha). I just tried t.deltaX, but do you know in which touch state I would put that in? Beginning, moving, or ended?

@YoloSwag I you want the object to release when the user stops moving, then you would check for a difference in the state MOVING. If there isn’t a difference, then release the object.

@YoloSwag Ignore my response above. If you’re not moving your finger on the screen, then you’re not entering the “touched” function. So putting code in the “touched” routine to determine if you’re not moving won’t work. Here’s an example that should work. Slide you’r finger around and then stop. As long as you don’t lift your finger, it will tell you you’re not moving.

``````
displayMode(FULLSCREEN)

function setup()
cnt=0
end

function draw()
background(40, 40, 50)
fill(255)
if tch and cnt>3 then
text("not moving",WIDTH/2,HEIGHT/2)
end
cnt=cnt+1
end

function touched(t)
if t.state==BEGAN then
tch=true
end
if t.state==MOVING then
cnt=0
end
if t.state==ENDED then
tch=false
end
end

``````