starling-framework
Version:
A fast, productive library for 2D cross-platform development.
157 lines • 5.98 kB
TypeScript
import DisplayObject from "../display/DisplayObject";
import Point from "openfl/geom/Point";
declare namespace starling.events {
/**
* A Touch object contains information about the presence or movement of a finger
* * or the mouse on the screen.
* *
* * <p>You receive objects of this type from a TouchEvent. When such an event is triggered,
* * you can query it for all touches that are currently present on the screen. One touch
* * object contains information about a single touch; it always transitions through a series
* * of TouchPhases. Have a look at the TouchPhase class for more information.</p>
* *
* * <strong>The position of a touch</strong>
* *
* * <p>You can get the current and previous position in stage coordinates with the 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.</p>
* *
* * @see TouchEvent
* * @see TouchPhase
*
*/
export class Touch {
/**
* Creates a new Touch object.
*/
constructor(id: number);
/**
* Converts the current location of a touch to the local coordinate system of a display
* * object. If you pass an <code>out</code>-point, the result will be stored in this point
* * instead of creating a new object.
*/
getLocation(space: DisplayObject, out?: Point): Point;
/**
* Converts the previous location of a touch to the local coordinate system of a display
* * object. If you pass an <code>out</code>-point, the result will be stored in this point
* * instead of creating a new object.
*/
getPreviousLocation(space: DisplayObject, out?: Point): Point;
/**
* Converts the start location of a touch (i.e. when it entered 'TouchPhase.BEGAN') to
* * the local coordinate system of a display object. If you pass an <code>out</code>-point,
* * the result will be stored in this point instead of creating a new object.
*/
getStartLocation(space: DisplayObject, out?: Point): Point;
/**
* Returns the movement of the touch between the current and previous location.
* * If you pass an <code>out</code>-point, the result will be stored in this point instead
* * of creating a new object.
*/
getMovement(space: DisplayObject, out?: Point): Point;
/**
* Returns the movement of the touch between the current and the start location.
* * If you pass an <code>out</code>-point, the result will be stored in this point instead
* * of creating a new object.
*/
getMovementSinceStart(space: DisplayObject, out?: Point): Point;
/**
* Indicates if the target or one of its children is touched.
*/
isTouching(target: DisplayObject): boolean;
/**
* Returns a description of the object.
*/
toString(): string;
/**
* Creates a clone of the Touch object.
*/
clone(): Touch;
/**
* The identifier of a touch. '0' for mouse events, an increasing number for touches.
*/
get id(): number;
/**
* The previous x-position of the touch in stage coordinates.
*/
get previousGlobalX(): number;
/**
* The previous y-position of the touch in stage coordinates.
*/
get previousGlobalY(): number;
/**
* The x-position of the touch when it was in 'TouchPhase.BEGAN', in stage coordinates.
* * (Or, if the touch is in phase 'HOVER', the x-position when it first appeared.)
*/
get startGlobalX(): number;
/**
* The y-position of the touch when it was in 'TouchPhase.BEGAN', in stage coordinates.
* * (Or, if the touch is in phase 'HOVER', the y-position when it first appeared.)
*/
get startGlobalY(): number;
/**
* The x-position of the touch in stage coordinates. If you change this value,
* * the previous one will be moved to "previousGlobalX".
*/
get globalX(): number;
set globalX(value: number)
/**
* The y-position of the touch in stage coordinates. If you change this value,
* * the previous one will be moved to "previousGlobalY".
*/
get globalY(): number;
set globalY(value: number)
/**
* The number of taps the finger made in a short amount of time. Use this to detect
* * double-taps / double-clicks, etc.
*/
get tapCount(): number;
set tapCount(value: number)
/**
* The current phase the touch is in. @see TouchPhase
*/
get phase(): string;
set phase(value: string)
/**
* The display object at which the touch occurred.
*/
get target(): DisplayObject;
set target(value: DisplayObject)
/**
* The moment the touch occurred (in seconds since application start).
*/
get timestamp(): number;
set timestamp(value: number)
/**
* A value between 0.0 and 1.0 indicating force of the contact with the device.
* * If the device does not support detecting the pressure, the value is 1.0.
*/
get pressure(): number;
set pressure(value: number)
/**
* Width of the contact area.
* * If the device does not support detecting the pressure, the value is 1.0.
*/
get width(): number;
set width(value: number)
/**
* Height of the contact area.
* * If the device does not support detecting the pressure, the value is 1.0.
*/
get height(): number;
set height(value: number)
/**
* Indicates if the touch has been cancelled, which may happen when the app moves into
* * the background ('Event.DEACTIVATE'). @default false
*/
get cancelled(): boolean;
set cancelled(value: boolean)
/**
* If the touch is hovering, returns the time (in seconds) since the touch was created;
* * afterwards, the time since the touch was in phase 'BEGAN'.
*/
get duration(): number;
}
}
export default starling.events.Touch;