The TouchProcessor is used to convert mouse and touch events of the conventional Flash stage to Starling's TouchEvents.

The Starling instance listens to mouse and touch events on the native stage. The attributes of those events are enqueued (right as they are happening) in the TouchProcessor.

Once per frame, the "advanceTime" method is called. It analyzes the touch queue and figures out which touches are active at that moment; the properties of all touch objects are updated accordingly.

Once the list of touches has been finalized, the "processTouches" method is called (that might happen several times in one "advanceTime" execution; no information is discarded). It's responsible for dispatching the actual touch events to the Starling display tree.

Subclassing TouchProcessor

You can extend the TouchProcessor if you need to have more control over touch and mouse input. For example, you could filter the touches by overriding the "processTouches" method, throwing away any touches you're not interested in and passing the rest to the super implementation.

To use your custom TouchProcessor, assign it to the "Starling.touchProcessor" property.

Note that you should not dispatch TouchEvents yourself, since they are much more complex to handle than conventional events (e.g. it must be made sure that an object receives a TouchEvent only once, even if it's manipulated with several fingers). Always use the base implementation of "processTouches" to let them be dispatched. That said: you can always dispatch your own custom events, of course.

### Hierarchy

- TouchProcessor

## Index

### Constructors

- constructor

### Properties

- multitapDistance
- multitapTime
- numCurrentTouches
- root
- simulateMultitouch
- stage

### Methods

- advanceTime
- cancelTouches
- dispose
- enqueue
- enqueueMouseLeftStage
- get_multitapDistance
- get_multitapTime
- get_numCurrentTouches
- get_root
- get_simulateMultitouch
- get_stage
- set_multitapDistance
- set_multitapTime
- set_root
- set_simulateMultitouch

## Constructors

### constructor

- new TouchProcessor(stage: Stage): TouchProcessor

- - Defined in lib/starling/events/TouchProcessor.d.ts:47

  Creates a new TouchProcessor that will dispatch events to the given stage.

  #### Parameters

  - ##### stage: Stage

  #### Returns TouchProcessor

## Properties

### multitapDistance

multitapDistance: number

- Defined in lib/starling/events/TouchProcessor.d.ts:91

The distance (in points) describing how close two touches must be to each other to be recognized as a multitap gesture.

### multitapTime

multitapTime: number

- Defined in lib/starling/events/TouchProcessor.d.ts:85

The time period (in seconds) in which two touches must occur to be recognized as a multitap gesture.

### numCurrentTouches

numCurrentTouches: number

- Defined in lib/starling/events/TouchProcessor.d.ts:107

Returns the number of fingers / touch points that are currently on the stage.

### root

root: DisplayObject

- Defined in lib/starling/events/TouchProcessor.d.ts:98

The base object that will be used for hit testing. Per default, this reference points to the stage; however, you can limit touch processing to certain parts of your game by assigning a different object.

### simulateMultitouch

simulateMultitouch: boolean

- Defined in lib/starling/events/TouchProcessor.d.ts:79

Indicates if it multitouch simulation should be activated. When the user presses ctrl/cmd (and optionally shift), he'll see a second touch curser that mimics the first. That's an easy way to develop and test multitouch when there's only a mouse available.

### stage

stage: Stage

- Defined in lib/starling/events/TouchProcessor.d.ts:103

The stage object to which the touch objects are (per default) dispatched.

## Methods

### advanceTime

- advanceTime(passedTime: number): void

- - Defined in lib/starling/events/TouchProcessor.d.ts:56

  Analyzes the current touch queue and processes the list of current touches, emptying the queue while doing so. This method is called by Starling once per frame.

  #### Parameters

  - ##### passedTime: number

  #### Returns void

### cancelTouches

- cancelTouches(): void

- - Defined in lib/starling/events/TouchProcessor.d.ts:73

  Force-end all current touches. Changes the phase of all touches to 'ENDED' and immediately dispatches a new TouchEvent (if touches are present). Called automatically when the app receives a 'DEACTIVATE' event.

  #### Returns void

### dispose

- dispose(): void

- - Defined in lib/starling/events/TouchProcessor.d.ts:52

  Removes all event handlers on the stage and releases any acquired resources.

  #### Returns void

### enqueue

- enqueue(touchID: number, phase: string, globalX: number, globalY: number, pressure?: number, width?: number, height?: number): void

- - Defined in lib/starling/events/TouchProcessor.d.ts:59

  Enqueues a new touch our mouse event with the given properties.

  #### Parameters

  - ##### touchID: number

  - ##### phase: string

  - ##### globalX: number

  - ##### globalY: number

  - ##### Optional pressure: number

  - ##### Optional width: number

  - ##### Optional height: number

  #### Returns void

### enqueueMouseLeftStage

- enqueueMouseLeftStage(): void

- - Defined in lib/starling/events/TouchProcessor.d.ts:68

  Enqueues an artificial touch that represents the mouse leaving the stage.

  On OS X, we get mouse events from outside the stage; on Windows, we do not. This method enqueues an artificial hover point that is just outside the stage. That way, objects listening for HOVERs over them will get notified everywhere.

  #### Returns void

### Protected get_multitapDistance

- get_multitapDistance(): number

- - Defined in lib/starling/events/TouchProcessor.d.ts:92

  #### Returns number

### Protected get_multitapTime

- get_multitapTime(): number

- - Defined in lib/starling/events/TouchProcessor.d.ts:86

  #### Returns number

### Protected get_numCurrentTouches

- get_numCurrentTouches(): number

- - Defined in lib/starling/events/TouchProcessor.d.ts:108

  #### Returns number

### Protected get_root

- get_root(): DisplayObject

- - Defined in lib/starling/events/TouchProcessor.d.ts:99

  #### Returns DisplayObject

### Protected get_simulateMultitouch

- get_simulateMultitouch(): boolean

- - Defined in lib/starling/events/TouchProcessor.d.ts:80

  #### Returns boolean

### Protected get_stage

- get_stage(): Stage

- - Defined in lib/starling/events/TouchProcessor.d.ts:104

  #### Returns Stage

### Protected set_multitapDistance

- set_multitapDistance(value: number): number

- - Defined in lib/starling/events/TouchProcessor.d.ts:93

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_multitapTime

- set_multitapTime(value: number): number

- - Defined in lib/starling/events/TouchProcessor.d.ts:87

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_root

- set_root(value: DisplayObject): DisplayObject

- - Defined in lib/starling/events/TouchProcessor.d.ts:100

  #### Parameters

  - ##### value: DisplayObject

  #### Returns DisplayObject

### Protected set_simulateMultitouch

- set_simulateMultitouch(value: boolean): boolean

- - Defined in lib/starling/events/TouchProcessor.d.ts:81

  #### Parameters

  - ##### value: boolean

  #### Returns boolean

Generated using TypeDoc