|
* `touchStarted()`
* `touchEnded()`
* `touchMoved()`
-In p5.js 2.0, instead of having separate methods for mouse and touch, we now use the browser's pointer API to handle both simultaneously. Try defining mouse functions as usual and accessing the global touches array to see what pointers are active for multitouch support!
+ |
+
+```js
+// On a touchscreen device, touch the canvas using one or more fingers
+// at the same time.
+
+function setup() {
+ createCanvas(100, 100);
+
+ describe(
+ 'A gray square. White circles appear where the user touches the square.'
+ );
+}
+
+function draw() {
+ background(200);
+
+ // Draw a circle at each touch point.
+ for (let touch of touches) {
+ circle(touch.x, touch.y, 40);
+ }
+}
+```
+
+ |
+