Game Development Reference
In-Depth Information
Understanding touch events
Although similar in nature to an ordinary mouse click, a touch event allows us to in-
teract with the computer primarily through a point and respond manner. However,
touches are far more flexible than clicks and thus open up the stage for a whole new
type of game.
Fundamentally, a touch is different than a click in that more than one touch is possible
on the same surface, at the same time. Also, a touch is generally different than a click
in that it allows for a larger target area as well as varying pressure. I say generally
because not all devices detect the touch area with high precision (or with any preci-
sion at all) or touch pressure. Similarly, some mouse or other equivalent input devices
actually do offer pressure sensitivity, although most browsers don't have use of such
a feature, neither do they expose that data through a click event object.
Note
For compatibility purposes, most mobile browsers respond to touch events when
JavaScript code expects a touch. In other words, a click handler can be triggered
by the user touching the screen. In this case, a regular click event object is passed
to the registered callback function and not a touch event object. Furthermore,
the experience might differ between a drag event (the dragMove event) and a
touch move event. Finally, multiple touches may or may not trigger simultaneous
click event listeners.
There are three events related to touch, namely touch start, touch move, and touch
end. Touch start and touch end can be related to the mouse down and mouse up
events respectively, while a touch move event is similar to a drag move event.
touchstart
This event is triggered when the touch area detects a new touch, whether or not one
or more touch events have already started and have not yet ended.
Search WWH ::




Custom Search