How to move pad with touch

let position1 = 100;
let position2 = 100;

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  
  rect(0,position2,10,100);
  rect(width-10,position1,10,100);
  
  if(mouseX > width/2){
    position1= mouseY;
  }
  if(mouseX < width/2){
    position2= mouseY;
  }
  
}

i want to do the same thing but on a mobile service but i don’t know how to do that

Hi,

Check out the touch section on the p5js reference :

thank you i have done

1 Like