Game Development Reference
In-Depth Information
// Cancel the default behavior for a drag
gesture,
// so that the application doesn't scroll.
document.body.addEventListener("touchmove",
function(event) {
event.preventDefault();
});
// Register our function for all the touch
events we want to track.
document.body.addEventListener("touchstart",
addTouch);
document.body.addEventListener("touchend",
addTouch);
document.body.addEventListener("touchmove",
addTouch);
// The render loop
(function render() {
clearMarks();
drawTouches();
requestAnimationFrame(render);
})();
An example of multi touch taking into account the radius of each touch is illustrated
as follows. By touching the side of a closed fist to a mobile device, we can see how
each part of the hand that touches the screen is detected with their relative size and
area of contact.
Search WWH ::




Custom Search