Java Reference
In-Depth Information
ture.
Touch Event Properties
Because it is possible to touch a surface many times at once, touch event objects have a
property called
event.touches
. This is a list of touch objects that represents all the
touches taking place on that device. It has a
length
property that tells you how many
touch points
(usually the user's fingers, but could be a stylus) are in contact with the sur-
face. Each touch object in the list can be accessed using index notation. For example, if a
user touches the screen with two fingers,
events.touches.length
would return
2
.
The first touch object can be accessed using
events.touches[0]
and the second us-
ing
events.touches[1]
.
Each touch object has a number of properties, many similar to the
event
object, such
as
touch.screenX
and
touch.screenY
to find the coordinates where the finger
is touching the screen. They have other properties such as
touch.radiusX
and
touch.radiusY
, which give an indication of the area covered by the touch, and
touch.force
, which returns the amount of pressure being applied by the touch as a
value between
0
and
1
.
Each touch object has a
touch.identifier
property, a unique ID that can be used to
ensure you are dealing with the same touch.
More information about touch events can be found on
JavaScript Kit,
although, be warned,
they are complex and difficult to implement. It can be handy to use a library such as
Ham-