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

Properties

  •   timestamp

    The moment the event occurred (in seconds since application start).

    property
  •   globalX

    The x-position of the touch in screen coordinates

    property
  •   globalY

    The y-position of the touch in screen coordinates

    property
  •   previousGlobalX

    The previous x-position of the touch in screen coordinates

    property
  •   previousGlobalY

    The previous y-position of the touch in screen coordinates

    property
  •   tapCount

    The number of taps the finger made in a short amount of time. Use this to detect double-taps, etc.

    property
  •   phase

    The current phase the touch is in.

    property
  •   target

    The display object at which the touch occurred.

    property

Properties

globalX

The x-position of the touch in screen coordinates

@property (nonatomic, readonly) float globalX

Discussion

The x-position of the touch in screen coordinates

Declared In

SPTouch.h

globalY

The y-position of the touch in screen coordinates

@property (nonatomic, readonly) float globalY

Discussion

The y-position of the touch in screen coordinates

Declared In

SPTouch.h

phase

The current phase the touch is in.

@property (nonatomic, readonly) SPTouchPhase phase

Discussion

The current phase the touch is in.

Declared In

SPTouch.h

previousGlobalX

The previous x-position of the touch in screen coordinates

@property (nonatomic, readonly) float previousGlobalX

Discussion

The previous x-position of the touch in screen coordinates

Declared In

SPTouch.h

previousGlobalY

The previous y-position of the touch in screen coordinates

@property (nonatomic, readonly) float previousGlobalY

Discussion

The previous y-position of the touch in screen coordinates

Declared In

SPTouch.h

tapCount

The number of taps the finger made in a short amount of time. Use this to detect double-taps, etc.

@property (nonatomic, readonly) int tapCount

Discussion

The number of taps the finger made in a short amount of time. Use this to detect double-taps, etc.

Declared In

SPTouch.h

target

The display object at which the touch occurred.

@property (nonatomic, readonly) SPDisplayObject *target

Discussion

The display object at which the touch occurred.

Declared In

SPTouch.h

timestamp

The moment the event occurred (in seconds since application start).

@property (nonatomic, readonly) double timestamp

Discussion

The moment the event occurred (in seconds since application start).

Declared In

SPTouch.h

Instance Methods

locationInSpace:

Converts the current location of a touch to the local coordinate system of a display object.

- (SPPoint *)locationInSpace:(SPDisplayObject *)space

Discussion

Converts the current location of a touch to the local coordinate system of a display object.

Declared In

SPTouch.h

movementInSpace:

Returns the movement of the touch between the current and previous location.

- (SPPoint *)movementInSpace:(SPDisplayObject *)space

Discussion

Returns the movement of the touch between the current and previous location.

Declared In

SPTouch.h

previousLocationInSpace:

Converts the previous location of a touch to the local coordinate system of a display object.

- (SPPoint *)previousLocationInSpace:(SPDisplayObject *)space

Discussion

Converts the previous location of a touch to the local coordinate system of a display object.

Declared In

SPTouch.h