import Touch from "./Touch"; import EventDispatcher from "./EventDispatcher"; import Event from "./Event"; import DisplayObject from "../display/DisplayObject"; import Vector from "openfl/Vector"; declare namespace starling.events { /** * A TouchEvent is triggered either by touch or mouse input. * * * *
In Starling, both touch events and mouse events are handled through the same class:
* * TouchEvent. To process user input from a touch screen or the mouse, you have to register
* * an event listener for events of the type TouchEvent.TOUCH. This is the only
* * event type you need to handle; the long list of mouse event types as they are used in
* * conventional Flash are mapped to so-called "TouchPhases" instead.
The difference between mouse input and touch input is that
* * * *In Starling, any display object receives touch events, as long as the
* * touchable property of the object and its parents is enabled. There
* * is no "InteractiveObject" class in Starling.
The event contains a list of all touches that are currently present. Each individual * * touch is stored in an object of type "Touch". Since you are normally only interested in * * the touches that occurred on top of certain objects, you can query the event for touches * * with a specific target:
* * * *var touches:Vector.<Touch> = touchEvent.getTouches(this);
* *
* * This will return all touches of "this" or one of its children. When you are not using * * multitouch, you can also access the touch object directly, like this:
* * * *var touch:Touch = touchEvent.getTouch(this);
* *
* * @see Touch
* * @see TouchPhase
*
*/
export class TouchEvent extends Event {
/**
* Creates a new TouchEvent instance.
*/
constructor(type: string, touches?: Vectorout-vector, the touches will be added to this vector instead of creating
* * a new object.
*/
getTouches(target: DisplayObject, phase?: string, out?: Vector