starling-framework
Version:
A fast, productive library for 2D cross-platform development.
133 lines • 6.23 kB
TypeScript
import Stage from "../display/Stage";
import DisplayObject from "../display/DisplayObject";
declare namespace starling.events {
/**
* The TouchProcessor is used to convert mouse and touch events of the conventional
* * Flash stage to Starling's TouchEvents.
* *
* * <p>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.</p>
* *
* * <p>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.</p>
* *
* * <p>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.</p>
* *
* * <strong>Subclassing TouchProcessor</strong>
* *
* * <p>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.</p>
* *
* * <p>To use your custom TouchProcessor, assign it to the "Starling.touchProcessor"
* * property.</p>
* *
* * <p>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.</p>
*
*/
export class TouchProcessor {
/**
* Creates a new TouchProcessor that will dispatch events to the given stage.
*/
constructor(stage: Stage);
/**
* Removes all event handlers on the stage and releases any acquired resources.
*/
dispose(): void;
/**
* 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.
*/
advanceTime(passedTime: number): void;
/**
* Enqueues a new touch or mouse event with the given properties.
*/
enqueue(touchID: number, phase: string, globalX: number, globalY: number, pressure?: number, width?: number, height?: number): void;
/**
* Enqueues an artificial touch that represents the mouse leaving the stage.
* *
* * <p>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.</p>
*
*/
enqueueMouseLeftStage(): void;
/**
* 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.
*/
cancelTouches(): void;
/**
* Configures the margins within which, when a touch is starting, it's considered to be
* * a system gesture (in points). Note that you also need to enable 'ignoreSystemGestures'.
*
*/
setSystemGestureMargins(topMargin?: number, bottomMargin?: number, leftMargin?: number, rightMargin?: number): void;
/**
* 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.
*
*/
get simulateMultitouch(): boolean;
set simulateMultitouch(value: boolean)
/**
* The time period (in seconds) in which two touches must occur to be recognized as
* * a multitap gesture.
*/
get multitapTime(): number;
set multitapTime(value: number)
/**
* The distance (in points) describing how close two touches must be to each other to
* * be recognized as a multitap gesture.
*/
get multitapDistance(): number;
set multitapDistance(value: number)
/**
* 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.
*/
get root(): DisplayObject;
set root(value: DisplayObject)
/**
* The stage object to which the touch objects are (per default) dispatched.
*/
get stage(): Stage;
/**
* Returns the number of fingers / touch points that are currently on the stage.
*/
get numCurrentTouches(): number;
/**
* If this callback returns <code>false</code>, the corresponding touch will have its
* * target set to <code>null</code>, which will prevent the original target from being
* * notified of the touch. In other words: the touch is being blocked. Callback format:
* * <pre>function(stageX:Number, stageY:Number):Boolean;</pre>
* * @default null
*
*/
get occlusionTest(): (arg0: number, arg1: number) => boolean;
set occlusionTest(value: (arg0: number, arg1: number) => boolean)
/**
* When enabled, all touches that start very close to the window edges are discarded.
* * On mobile, such touches often indicate swipes that are meant to open OS menus.
* * Per default, margins of 10 points at the very top and bottom of the screen are checked.
* * Call 'setSystemGestureMargins()' to adapt the margins in each direction.
* * @default true on mobile, false on desktop
*/
get discardSystemGestures(): boolean;
set discardSystemGestures(value: boolean)
}
}
export default starling.events.TouchProcessor;