Class

CHHapticEvent

An object that describes a single haptic or audio event.

Declaration

@interface CHHapticEvent : NSObject

Overview

Each event represents a single haptic or audio signal. The event type determines whether it is audio or haptic. Use a CHHapticPatternPlayer object obtained through CHHapticEngine factory methods to play events. Haptic events can be transient or continuous. Transient haptic patterns are brief impulses that occur at a specific point in time, such as the haptic feedback you feel from swiping through a picker or toggling a switch. Continuous haptic patterns, like the vibration from a ringtone, take the form of lengthier feedback over a period of time.

In the following graphic, transient haptic patterns on the left trigger at a specific time with a specific intensity. Continuous haptic patterns on the right sustain the haptic feedback over a specific duration of time, such as three seconds.

A transient haptic pattern on the left, and a continuous haptic pattern on the right.

Specify when an event begins by setting its relativeTime property. Specify the length of the event by setting its duration property. Set optional parameters to customize event properties. For example, you can specify the intensity of a haptic event by creating an event parameter with ID CHHapticEventParameterIDHapticIntensity.

Topics

Categorizing Haptic Events

type

The type of the haptic event.

CHHapticEventType

The types of audio and haptic event waveforms.

Creating Haptic Events

- initWithAudioResourceID:parameters:relativeTime:

Initializes a haptic event from a previously loaded audio resource, specifying event parameters and start time.

- initWithAudioResourceID:parameters:relativeTime:duration:

Initializes a haptic event from a previously loaded audio resource, specifying event parameters, start time, and duration.

- initWithEventType:parameters:relativeTime:

Initializes a haptic event of the specified type, parameters, and start time.

- initWithEventType:parameters:relativeTime:duration:

Initializes a haptic event of the specified type, parameters, start time, and duration.

Configuring Haptic Events

eventParameters

An array of event parameters, possibly empty.

CHHapticEventParameterID

An identifier that indicates the event parameter being defined.

relativeTime

The start time of the event, relative to other events in the same pattern.

duration

The duration of the haptic event.

Relationships

Inherits From

See Also

Programmatic Haptics

Playing Collision-Based Haptic Patterns

Play a custom haptic pattern whose strength depends on an object’s collision speed.

Updating Continuous and Transient Haptic Parameters in Real Time

Generate continuous and transient haptic patterns in response to user touch.

CHHapticEventParameter

A static parameter value that represents a single property of the haptic pattern.

CHHapticDynamicParameter

A value that you send to a haptic pattern player to alter a property value during playback.

CHHapticParameterCurve

A curve that you send to a haptic pattern player to alter a property value gradually during playback.