import type Application from "../application/application.ts"; import type { Vector2d } from "../math/vector2d.ts"; import Pointer from "./pointer.ts"; /** * reference to the active application instance * @ignore */ export declare let _app: Application; /** * the default target element for pointer events (usually the canvas element in which the game is rendered) */ export declare let pointerEventTarget: EventTarget | null; /** * Pointer information (current position and size) */ export declare const pointer: Pointer; /** * indicates if the pointer is currently locked */ export declare let locked: boolean; /** * time interval for event throttling in milliseconds
* default value : "1000/me.timer.maxfps" ms
* set to 0 ms to disable the feature */ export declare let throttlingInterval: number | undefined; /** * return true if there are pending pointer events in the queue * @returns true if there are pending events */ export declare function hasActiveEvents(): boolean; /** * return true if there are register pointer events * @see {@link registerPointerEvent} * @returns true if there are pending events */ export declare function hasRegisteredEvents(): boolean; /** * Translate the specified x and y values from the global (absolute) * coordinate to local (viewport) relative coordinate. * @param x - the global x coordinate to be translated. * @param y - the global y coordinate to be translated. * @param v - an optional vector object where to set the translated coordinates * @returns A vector object with the corresponding translated coordinates * @example * onMouseEvent : function (pointer) { * // convert the given into local (viewport) relative coordinates * let pos = me.input.globalToLocal(pointer.clientX, pointer.clientY); * // do something with pos ! * }; */ export declare function globalToLocal(x: number, y: number, v?: Vector2d): Vector2d; /** * enable/disable all gestures on the given element.
* by default melonJS will disable browser handling of all panning and zooming gestures. * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action} * @param element - the HTML element to configure * @param value - the touch-action CSS value */ export declare function setTouchAction(element: HTMLCanvasElement, value?: string): void; /** * Associate a pointer event to a keycode
* Left button -- 0 * Middle button -- 1 * Right button -- 2 * @param args - button and/or keyCode * @example * // enable the keyboard * me.input.bindKey(me.input.KEY.X, "shoot"); * // map the left button click on the X key (default if the button is not specified) * me.input.bindPointer(me.input.KEY.X); * // map the right button click on the X key * me.input.bindPointer(me.input.pointer.RIGHT, me.input.KEY.X); */ export declare function bindPointer(...args: number[]): void; /** * unbind the defined keycode * @param button - (accordingly to W3C values : 0,1,2 for left, middle and right buttons) * @example * me.input.unbindPointer(me.input.pointer.LEFT); */ export declare function unbindPointer(button?: number): void; /** * allows registration of event listeners on the object target.
* melonJS will pass a me.Pointer object to the defined callback. * @see Pointer * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events | W3C Pointer Event list} * @param eventType - The event type for which the object is registering
* melonJS currently supports:
* * @param region - a shape representing the region to register on * @param callback - methods to be called when the event occurs. * Returning `false` from the defined callback will prevent the event to be propagated to other objects * @example * // onActivate function * onActivateEvent: function () { * // register on the 'pointerdown' event * me.input.registerPointerEvent('pointerdown', this, (e) => this.pointerDown(e)); * }, * * // pointerDown event callback * pointerDown: function (pointer) { * // do something * .... * // don"t propagate the event to other objects * return false; * }, */ export declare function registerPointerEvent(eventType: string, region: any, callback: (pointer: Pointer) => boolean | void): void; /** * allows the removal of event listeners from the object target. * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list} * @param eventType - The event type for which the object was registered. See {@link input.registerPointerEvent} * @param region - the registered region to release for this event * @param callback - if specified unregister the event only for the specific callback * @example * // release the registered region on the 'pointerdown' event * me.input.releasePointerEvent('pointerdown', this); */ export declare function releasePointerEvent(eventType: string, region: any, callback?: (pointer: Pointer) => boolean | void): void; /** * allows the removal of all registered event listeners from the object target. * @param region - the registered region to release event from * @example * // release all registered event on the * me.input.releaseAllPointerEvents(this); */ export declare function releaseAllPointerEvents(region: any): void; /** * request for the pointer to be locked on the parent DOM element. * (Must be called in a click event or an event that requires user interaction) * @returns return true if the request was successfully submitted * @example * // register on the pointer lock change event * event.on(event.POINTERLOCKCHANGE, (locked)=> { * console.log("pointer lock: " + locked); * }); * // request for pointer lock * me.input.requestPointerLock(); */ export declare function requestPointerLock(): boolean; /** * Initiates an exit from pointer lock state * @returns return true if the request was successfully submitted */ export declare function exitPointerLock(): boolean; //# sourceMappingURL=pointerevent.d.ts.map