A function that's called once each time a screen touch ends.
Declaring the function touchEnded() sets a code block to run automatically when the user stops touching a touchscreen device:
function touchEnded() {
// Code to run.
}
The touches array will be updated with the most recent touch points when touchEnded() is called by p5.js:
function touchEnded() {
// Paint over the background.
background(200);
// Mark each remaining touch point when the user stops
// a touch.
for (let touch of touches) {
circle(touch.x, touch.y, 40);
}
}
The parameter, event, is optional. touchEnded() will be passed a TouchEvent object with properties that describe the touch event:
function touchEnded(event) {
// Code to run that uses the event.
console.log(event);
}
On touchscreen devices, mouseReleased() will run when the user’s touch ends if touchEnded() isn’t declared. If touchEnded() is declared, then touchEnded() will run when a user’s touch ends and mouseReleased() won’t.
Note: touchStarted(), touchEnded(), and touchMoved() are all related. touchStarted() runs as soon as the user touches a touchscreen device. touchEnded() runs as soon as the user ends a touch. touchMoved() runs repeatedly as the user moves any touch points.
Ejemplos
Sintaxis
touchEnded([event])
Parámetros
optional TouchEvent argument.
Referencias Relacionadas
touchEnded
Una función que se ejecuta una vez por cada toque en la pantalla que termina.
touches
Un Array de todos los puntos táctiles actuales en un dispositivo táctil.
touchMoved
Una función que se ejecuta cada vez que el usuario toca la pantalla y se mueve.
touchStarted
Una función que se ejecuta una vez por cada vez que el usuario toca la pantalla.