Okay so I dissected your example code Dave (thank you for that) and I fully understand how multi-touch sensors work but I after 2 hours of test programming, I have 2 follow up questions:

(And here’s my code if you’d like to copy it and run to get a better idea…I started fiddling with a circle and using joysticks to modify with it’s vector properties…

```
-- MyTouches
-- Use this function to perform your initial setup
function setup()
touches={}
count=1
ball = physics.body(CIRCLE,45)
ball.x = WIDTH/2
ball.y = HEIGHT/2
ball.r=170
ball.g =170
w1= physics.body(EDGE, vec2(0,0),vec2(WIDTH,0))
w2 = physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
w3=physics.body(EDGE,vec2(0,HEIGHT),vec2(WIDTH,HEIGHT))
w4=physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
for key, value in pairs(touches) do
value:draw()
end
-- Do your drawing here
noStroke()
fill(ball.r, ball.g, math.random(150,255), 255)
if ball.r > 255 then ball.r=255 end --sets limits on the color values
if ball.r<0 then ball.r=0 end
if ball.g > 255 then ball.g = 255 end
if ball.g < 0 then ball.g = 0 end
ellipse(ball.x,ball.y,ball.radius*2)
end
function touched(t)
-- table.insert(touches, addTouch(t.id,t.x,t.y) )
if(t.state == BEGAN) then
aa = 0--controller to see if the touch is already created
for key, value in pairs(touches) do
if(value.id == 0) then
value.x = t.x
value.y = t.y
value.id = t.id
aa=1
print(value.id.." "..value.x)--debug print
break
end
end
if(aa==0) then
table.insert(touches,addTouch(t.id,t.x,t.y))
end
else if(t.state == MOVING or t.state == ENDED) then
for key, value in pairs(touches)do
value:touched(t)
end
end
end
end
addTouch =class()
function addTouch:init(id,x,y)
self.x = x
self.y = y
self.dx=0
self.dy=0
self.count = count
count = count + 1
self.color = color(math.random(100,255), math.random(100,255),math.random(100,255))
self.id = id
end
function addTouch:touched(t)
if(t.state == MOVING) then
if(t.id == self.id) then
self.dx = (t.x)--/200
self.dy = (t.y)--/200
if(self.count==1)then
ball:applyForce(vec2((self.dx-self.x)/2,(self.dy-self.y)/2))
end
if(self.count==2)then--xval for second joystick controls r val, y =g val
ball.r = ball.r + (self.dx-self.x)/10
ball.g=ball.g+(self.dy-self.y)/10
end
end
end
if(t.state == ENDED) then
if(self.id == t.id) then
self.x =0
self.y=0
self.id=0
self.dx=0
self.dy=0
end
end
end
function addTouch:draw()
if self.id > 0 then
noFill()
stroke(self.color)
ellipse(self.dx,self.dy,40)
ellipse(self.x,self.y,200)
end
end
```

- When I’m not moving the joystick continuously, the force in the ball stops accelerating and the ball eventually crashes due to gravity. How can I make it so that just by holding the circle passively it will register as an active touch?
- How can I bind the moving circle joystick so that the It can not exit the larger circle?

Thank you for all your help!