SPTouch Class Reference
| Inherits from | NSObject |
| Declared in | SPTouch.h |
Overview
An SPTouch contains information about the presence or movement of a finger on the screen.
You receive objects of this type via an SPTouchEvent. When such an event is triggered, you can query it for all touches that are currently present on the screen. One SPTouch object contains information about a single touch.
The phase of a touch
Each touch normally moves through the following phases in its life:
Began -> Moved -> Ended
Furthermore, a touch can enter a STATIONARY phase. That phase does not
trigger a touch event itself, and it can only occur when ‘Multitouch’ is activated. Picture a
situation where one finger is moving and the other is stationary. A touch event will
be dispatched only to the object under the moving finger. In the list of touches of
that event, you will find the second touch in the stationary phase.
The position of a touch
You can get the current and last position on the screen with corresponding properties. However, you’ll want to have the position in a different coordinate system most of the time. For this reason, there are methods that convert the current and previous touches into the local coordinate system of any object.
Tasks
Methods
-
– locationInSpace:Converts the current location of a touch to the local coordinate system of a display object.
-
– previousLocationInSpace:Converts the previous location of a touch to the local coordinate system of a display object.
-
– movementInSpace:Returns the movement of the touch between the current and previous location.
Properties
-
timestampThe moment the event occurred (in seconds since application start).
property -
globalXThe x-position of the touch in screen coordinates
property -
globalYThe y-position of the touch in screen coordinates
property -
previousGlobalXThe previous x-position of the touch in screen coordinates
property -
previousGlobalYThe previous y-position of the touch in screen coordinates
property -
tapCountThe number of taps the finger made in a short amount of time. Use this to detect double-taps, etc.
property -
phaseThe current phase the touch is in.
property -
targetThe display object at which the touch occurred.
property
Properties
globalX
The x-position of the touch in screen coordinates
@property (nonatomic, readonly) float globalXDiscussion
The x-position of the touch in screen coordinates
Declared In
SPTouch.hglobalY
The y-position of the touch in screen coordinates
@property (nonatomic, readonly) float globalYDiscussion
The y-position of the touch in screen coordinates
Declared In
SPTouch.hphase
The current phase the touch is in.
@property (nonatomic, readonly) SPTouchPhase phaseDiscussion
The current phase the touch is in.
Declared In
SPTouch.hpreviousGlobalX
The previous x-position of the touch in screen coordinates
@property (nonatomic, readonly) float previousGlobalXDiscussion
The previous x-position of the touch in screen coordinates
Declared In
SPTouch.hpreviousGlobalY
The previous y-position of the touch in screen coordinates
@property (nonatomic, readonly) float previousGlobalYDiscussion
The previous y-position of the touch in screen coordinates
Declared In
SPTouch.htapCount
The number of taps the finger made in a short amount of time. Use this to detect double-taps, etc.
@property (nonatomic, readonly) int tapCountDiscussion
The number of taps the finger made in a short amount of time. Use this to detect double-taps, etc.
Declared In
SPTouch.hInstance Methods
locationInSpace:
Converts the current location of a touch to the local coordinate system of a display object.
- (SPPoint *)locationInSpace:(SPDisplayObject *)spaceDiscussion
Converts the current location of a touch to the local coordinate system of a display object.
Declared In
SPTouch.hmovementInSpace:
Returns the movement of the touch between the current and previous location.
- (SPPoint *)movementInSpace:(SPDisplayObject *)spaceDiscussion
Returns the movement of the touch between the current and previous location.
Declared In
SPTouch.hpreviousLocationInSpace:
Converts the previous location of a touch to the local coordinate system of a display object.
- (SPPoint *)previousLocationInSpace:(SPDisplayObject *)spaceDiscussion
Converts the previous location of a touch to the local coordinate system of a display object.
Declared In
SPTouch.h