melonjs 18.1.0 → 18.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/application/application.d.ts +29 -37
- package/build/application/application.d.ts.map +1 -1
- package/build/application/header.d.ts +3 -7
- package/build/application/header.d.ts.map +1 -1
- package/build/application/resize.d.ts +3 -4
- package/build/application/resize.d.ts.map +1 -1
- package/build/audio/audio.d.ts +145 -125
- package/build/audio/audio.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +192 -102
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/geometries/roundrect.d.ts +82 -17
- package/build/geometries/roundrect.d.ts.map +1 -1
- package/build/index.d.ts +12 -12
- package/build/index.js +2288 -842
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts +110 -61
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/input.d.ts +3 -7
- package/build/input/input.d.ts.map +1 -1
- package/build/input/pointer.d.ts +25 -51
- package/build/input/pointer.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts +51 -79
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/tiled/TMXGroup.d.ts +5 -0
- package/build/level/tiled/TMXGroup.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXObject.d.ts +21 -16
- package/build/level/tiled/TMXObject.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +16 -5
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +15 -3
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +136 -15
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXUtils.d.ts +31 -0
- package/build/level/tiled/TMXUtils.d.ts.map +1 -1
- package/build/level/tiled/constants.d.ts +1 -1
- package/build/level/tiled/constants.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +42 -0
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -0
- package/build/level/tiled/renderer/autodetect.d.ts +2 -1
- package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +1 -0
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +38 -121
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +1 -4
- package/build/particles/particle.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +1 -1
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/detector.d.ts.map +1 -1
- package/build/physics/world.d.ts +2 -2
- package/build/plugin/plugin.d.ts +36 -53
- package/build/plugin/plugin.d.ts.map +1 -1
- package/build/polyfill/ellipse.d.ts +2 -0
- package/build/polyfill/ellipse.d.ts.map +1 -0
- package/build/polyfill/index.d.ts +1 -0
- package/build/polyfill/index.d.ts.map +1 -1
- package/build/renderable/colorlayer.d.ts +2 -2
- package/build/renderable/container.d.ts +6 -6
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +11 -2
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/ui/uibaseelement.d.ts +46 -33
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uispriteelement.d.ts +53 -43
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +68 -74
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/stage.d.ts +1 -1
- package/build/state/state.d.ts +93 -90
- package/build/state/state.d.ts.map +1 -1
- package/build/system/event.d.ts +2 -2
- package/build/system/event.d.ts.map +1 -1
- package/build/utils/decode.d.ts +1 -0
- package/build/utils/decode.d.ts.map +1 -1
- package/build/utils/function.d.ts +1 -1
- package/build/utils/function.d.ts.map +1 -1
- package/build/utils/utils.d.ts +1 -1
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +40 -13
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +12 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +43 -8
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +33 -8
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/buffer/vertex.d.ts +9 -1
- package/build/video/webgl/buffer/vertex.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +22 -20
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
package/build/input/gamepad.d.ts
CHANGED
|
@@ -1,11 +1,78 @@
|
|
|
1
|
+
interface GamepadMapping {
|
|
2
|
+
axes: number[];
|
|
3
|
+
buttons: number[];
|
|
4
|
+
analog: number[];
|
|
5
|
+
normalize_fn: (value: number, axis: number, button: number) => number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Namespace for standard gamepad mapping constants
|
|
9
|
+
*/
|
|
10
|
+
export declare const GAMEPAD: {
|
|
11
|
+
/**
|
|
12
|
+
* Standard gamepad mapping information for axes<br>
|
|
13
|
+
* <ul>
|
|
14
|
+
* <li>Left control stick: <code>LX</code> (horizontal), <code>LY</code> (vertical)</li>
|
|
15
|
+
* <li>Right control stick: <code>RX</code> (horizontal), <code>RY</code> (vertical)</li>
|
|
16
|
+
* <li>Extras: <code>EXTRA_1</code>, <code>EXTRA_2</code>, <code>EXTRA_3</code>, <code>EXTRA_4</code></li>
|
|
17
|
+
* </ul>
|
|
18
|
+
* @see {@link https://w3c.github.io/gamepad/#remapping}
|
|
19
|
+
*/
|
|
20
|
+
readonly AXES: {
|
|
21
|
+
readonly LX: 0;
|
|
22
|
+
readonly LY: 1;
|
|
23
|
+
readonly RX: 2;
|
|
24
|
+
readonly RY: 3;
|
|
25
|
+
readonly EXTRA_1: 4;
|
|
26
|
+
readonly EXTRA_2: 5;
|
|
27
|
+
readonly EXTRA_3: 6;
|
|
28
|
+
readonly EXTRA_4: 7;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Standard gamepad mapping information for buttons<br>
|
|
32
|
+
* <ul>
|
|
33
|
+
* <li>Face buttons: <code>FACE_1</code>, <code>FACE_2</code>, <code>FACE_3</code>, <code>FACE_4</code></li>
|
|
34
|
+
* <li>D-Pad: <code>UP</code>, <code>DOWN</code>, <code>LEFT</code>, <code>RIGHT</code></li>
|
|
35
|
+
* <li>Shoulder buttons: <code>L1</code>, <code>L2</code>, <code>R1</code>, <code>R2</code></li>
|
|
36
|
+
* <li>Analog stick (clicks): <code>L3</code>, <code>R3</code></li>
|
|
37
|
+
* <li>Navigation: <code>SELECT</code> (<code>BACK</code>), <code>START</code> (<code>FORWARD</code>), <code>HOME</code></li>
|
|
38
|
+
* <li>Extras: <code>EXTRA_1</code>, <code>EXTRA_2</code>, <code>EXTRA_3</code>, <code>EXTRA_4</code></li>
|
|
39
|
+
* </ul>
|
|
40
|
+
* @see {@link https://w3c.github.io/gamepad/#remapping}
|
|
41
|
+
*/
|
|
42
|
+
readonly BUTTONS: {
|
|
43
|
+
readonly FACE_1: 0;
|
|
44
|
+
readonly FACE_2: 1;
|
|
45
|
+
readonly FACE_3: 2;
|
|
46
|
+
readonly FACE_4: 3;
|
|
47
|
+
readonly L1: 4;
|
|
48
|
+
readonly R1: 5;
|
|
49
|
+
readonly L2: 6;
|
|
50
|
+
readonly R2: 7;
|
|
51
|
+
readonly SELECT: 8;
|
|
52
|
+
readonly BACK: 8;
|
|
53
|
+
readonly START: 9;
|
|
54
|
+
readonly FORWARD: 9;
|
|
55
|
+
readonly L3: 10;
|
|
56
|
+
readonly R3: 11;
|
|
57
|
+
readonly UP: 12;
|
|
58
|
+
readonly DOWN: 13;
|
|
59
|
+
readonly LEFT: 14;
|
|
60
|
+
readonly RIGHT: 15;
|
|
61
|
+
readonly HOME: 16;
|
|
62
|
+
readonly EXTRA_1: 17;
|
|
63
|
+
readonly EXTRA_2: 18;
|
|
64
|
+
readonly EXTRA_3: 19;
|
|
65
|
+
readonly EXTRA_4: 20;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
1
68
|
/**
|
|
2
69
|
* Associate a gamepad event to a keycode
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
70
|
+
* @param index - Gamepad index
|
|
71
|
+
* @param button - Button/Axis definition
|
|
72
|
+
* @param button.type - "buttons" or "axes"
|
|
73
|
+
* @param button.code - button or axis code id
|
|
74
|
+
* @param button.threshold - value indicating when the axis should trigger the keycode
|
|
75
|
+
* @param keyCode - (See {@link input.KEY})
|
|
9
76
|
* @example
|
|
10
77
|
* // enable the keyboard
|
|
11
78
|
* me.input.bindKey(me.input.KEY.X, "shoot");
|
|
@@ -16,75 +83,57 @@
|
|
|
16
83
|
* me.input.bindGamepad(0, {type:"axes", code: me.input.GAMEPAD.AXES.LX, threshold: -0.5}, me.input.KEY.LEFT);
|
|
17
84
|
* @category Input
|
|
18
85
|
*/
|
|
19
|
-
export function bindGamepad(index: number, button: {
|
|
20
|
-
type:
|
|
86
|
+
export declare function bindGamepad(index: number, button: {
|
|
87
|
+
type: "buttons" | "axes";
|
|
21
88
|
code: number;
|
|
22
|
-
threshold?: number
|
|
89
|
+
threshold?: number;
|
|
23
90
|
}, keyCode: number): void;
|
|
24
91
|
/**
|
|
25
92
|
* unbind the defined keycode
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
93
|
+
* @param index - Gamepad index
|
|
94
|
+
* @param button - (See {@link input.GAMEPAD})
|
|
28
95
|
* @example
|
|
29
96
|
* me.input.unbindGamepad(0, me.input.GAMEPAD.BUTTONS.FACE_1);
|
|
30
97
|
* @category Input
|
|
31
98
|
*/
|
|
32
|
-
export function unbindGamepad(index: number, button: number): void;
|
|
99
|
+
export declare function unbindGamepad(index: number, button: number): void;
|
|
33
100
|
/**
|
|
34
101
|
* Set deadzone for analog gamepad inputs<br>
|
|
35
102
|
* The default deadzone is 0.1 (10%) Analog values less than this will be ignored
|
|
36
|
-
* @param
|
|
103
|
+
* @param value - Deadzone value
|
|
37
104
|
* @category Input
|
|
38
105
|
*/
|
|
39
|
-
export function setGamepadDeadzone(value: number): void;
|
|
40
|
-
export namespace GAMEPAD {
|
|
41
|
-
namespace AXES {
|
|
42
|
-
let LX: number;
|
|
43
|
-
let LY: number;
|
|
44
|
-
let RX: number;
|
|
45
|
-
let RY: number;
|
|
46
|
-
let EXTRA_1: number;
|
|
47
|
-
let EXTRA_2: number;
|
|
48
|
-
let EXTRA_3: number;
|
|
49
|
-
let EXTRA_4: number;
|
|
50
|
-
}
|
|
51
|
-
namespace BUTTONS {
|
|
52
|
-
export let FACE_1: number;
|
|
53
|
-
export let FACE_2: number;
|
|
54
|
-
export let FACE_3: number;
|
|
55
|
-
export let FACE_4: number;
|
|
56
|
-
export let L1: number;
|
|
57
|
-
export let R1: number;
|
|
58
|
-
export let L2: number;
|
|
59
|
-
export let R2: number;
|
|
60
|
-
export let SELECT: number;
|
|
61
|
-
export let BACK: number;
|
|
62
|
-
export let START: number;
|
|
63
|
-
export let FORWARD: number;
|
|
64
|
-
export let L3: number;
|
|
65
|
-
export let R3: number;
|
|
66
|
-
export let UP: number;
|
|
67
|
-
export let DOWN: number;
|
|
68
|
-
export let LEFT: number;
|
|
69
|
-
export let RIGHT: number;
|
|
70
|
-
export let HOME: number;
|
|
71
|
-
let EXTRA_1_1: number;
|
|
72
|
-
export { EXTRA_1_1 as EXTRA_1 };
|
|
73
|
-
let EXTRA_2_1: number;
|
|
74
|
-
export { EXTRA_2_1 as EXTRA_2 };
|
|
75
|
-
let EXTRA_3_1: number;
|
|
76
|
-
export { EXTRA_3_1 as EXTRA_3 };
|
|
77
|
-
let EXTRA_4_1: number;
|
|
78
|
-
export { EXTRA_4_1 as EXTRA_4 };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
106
|
+
export declare function setGamepadDeadzone(value: number): void;
|
|
81
107
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
108
|
+
* specify a custom mapping for a specific gamepad id<br>
|
|
109
|
+
* see below for the default mapping : <br>
|
|
110
|
+
* <center><img src="images/gamepad_diagram.png"/></center><br>
|
|
111
|
+
* @param id - Gamepad id string
|
|
112
|
+
* @param mapping - A hash table
|
|
113
|
+
* @example
|
|
114
|
+
* // A weird controller that has its axis mappings reversed
|
|
115
|
+
* me.input.setGamepadMapping("Generic USB Controller", {
|
|
116
|
+
* "axes" : [ 3, 2, 1, 0 ],
|
|
117
|
+
* "buttons" : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* // Mapping extra axes to analog buttons
|
|
121
|
+
* me.input.setGamepadMapping("Generic Analog Controller", {
|
|
122
|
+
* "axes" : [ 0, 1, 2, 3 ],
|
|
123
|
+
* "buttons" : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ],
|
|
124
|
+
*
|
|
125
|
+
* // Raw axis 4 is mapped to GAMEPAD.BUTTONS.FACE_1
|
|
126
|
+
* // Raw axis 5 is mapped to GAMEPAD.BUTTONS.FACE_2
|
|
127
|
+
* // etc...
|
|
128
|
+
* // Also maps left and right triggers
|
|
129
|
+
* "analog" : [ 4, 5, 6, 7, -1, -1, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 ],
|
|
85
130
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
131
|
+
* // Normalize the value of button L2: [-1.0..1.0] => [0.0..1.0]
|
|
132
|
+
* "normalize_fn" : function (value, axis, button) {
|
|
133
|
+
* return ((button === me.input.GAMEPAD.BUTTONS.L2) ? ((value + 1) / 2) : value) || 0;
|
|
134
|
+
* }
|
|
135
|
+
* });
|
|
88
136
|
*/
|
|
89
|
-
export
|
|
137
|
+
export declare const setGamepadMapping: (id: string, mapping: Partial<GamepadMapping>) => void;
|
|
138
|
+
export {};
|
|
90
139
|
//# sourceMappingURL=gamepad.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gamepad.d.ts","sourceRoot":"","sources":["../../src/input/gamepad.
|
|
1
|
+
{"version":3,"file":"gamepad.d.ts","sourceRoot":"","sources":["../../src/input/gamepad.ts"],"names":[],"mappings":"AASA,UAAU,cAAc;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACtE;AA2UD;;GAEG;AACH,eAAO,MAAM,OAAO;IACnB;;;;;;;;OAQG;;;;;;;;;;;IAYH;;;;;;;;;;;OAWG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BM,CAAC;AAEX;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE;IAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EACtE,OAAO,EAAE,MAAM,GACb,IAAI,CAuDN;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAKjE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,iBAAiB,EAAE,CAC/B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,KAC5B,IAAiB,CAAC"}
|
package/build/input/input.d.ts
CHANGED
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* specify if melonJS should prevent all default browser action on registered events.
|
|
6
|
-
* @public
|
|
7
|
-
* @type {boolean}
|
|
8
6
|
* @default true
|
|
9
|
-
* @name preventDefault
|
|
10
|
-
* @memberof input
|
|
11
7
|
*/
|
|
12
|
-
export let preventDefault: boolean;
|
|
13
|
-
export * from "./gamepad.
|
|
8
|
+
export declare let preventDefault: boolean;
|
|
9
|
+
export * from "./gamepad.ts";
|
|
14
10
|
export * from "./key.ts";
|
|
15
11
|
export * from "./keyboard.ts";
|
|
16
|
-
export * from "./pointerevent.
|
|
12
|
+
export * from "./pointerevent.ts";
|
|
17
13
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/input/input.
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/input/input.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AAEH,eAAO,IAAI,cAAc,EAAE,OAAc,CAAC;AAE1C,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/build/input/pointer.d.ts
CHANGED
|
@@ -1,180 +1,154 @@
|
|
|
1
|
-
|
|
1
|
+
import { Bounds } from "./../physics/bounds.ts";
|
|
2
2
|
/**
|
|
3
3
|
* a pointer object, representing a single finger on a touch enabled device.
|
|
4
4
|
*/
|
|
5
5
|
declare class Pointer extends Bounds {
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
constructor(x?: number, y?: number, w?: number, h?: number);
|
|
10
6
|
/**
|
|
11
7
|
* constant for left button
|
|
12
|
-
* @public
|
|
13
|
-
* @type {number}
|
|
14
8
|
*/
|
|
15
|
-
|
|
9
|
+
LEFT: number;
|
|
16
10
|
/**
|
|
17
11
|
* constant for middle button
|
|
18
|
-
* @public
|
|
19
|
-
* @type {number}
|
|
20
12
|
*/
|
|
21
|
-
|
|
13
|
+
MIDDLE: number;
|
|
22
14
|
/**
|
|
23
15
|
* constant for right button
|
|
24
|
-
* @public
|
|
25
|
-
* @type {number}
|
|
26
16
|
*/
|
|
27
|
-
|
|
17
|
+
RIGHT: number;
|
|
28
18
|
/**
|
|
29
19
|
* the originating Event Object
|
|
30
|
-
* @type {PointerEvent|TouchEvent|MouseEvent}
|
|
31
20
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent}
|
|
32
21
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent}
|
|
33
22
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent}
|
|
34
23
|
*/
|
|
35
|
-
event: PointerEvent | TouchEvent | MouseEvent;
|
|
24
|
+
event: PointerEvent | TouchEvent | MouseEvent | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* a string containing the event's type.
|
|
27
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Event/type}
|
|
28
|
+
*/
|
|
29
|
+
type: string;
|
|
36
30
|
/**
|
|
37
31
|
* the button property indicates which button was pressed on the mouse to trigger the event.
|
|
38
|
-
* @type {number}
|
|
39
32
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button}
|
|
40
33
|
*/
|
|
41
34
|
button: number;
|
|
42
35
|
/**
|
|
43
36
|
* indicates whether or not the pointer device that created the event is the primary pointer.
|
|
44
|
-
* @type {boolean}
|
|
45
37
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary}
|
|
46
38
|
*/
|
|
47
39
|
isPrimary: boolean;
|
|
48
40
|
/**
|
|
49
41
|
* the horizontal coordinate at which the event occurred, relative to the left edge of the entire document.
|
|
50
|
-
* @type {number}
|
|
51
42
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageX}
|
|
52
43
|
*/
|
|
53
44
|
pageX: number;
|
|
54
45
|
/**
|
|
55
46
|
* the vertical coordinate at which the event occurred, relative to the left edge of the entire document.
|
|
56
|
-
* @type {number}
|
|
57
47
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/pageY}
|
|
58
48
|
*/
|
|
59
49
|
pageY: number;
|
|
60
50
|
/**
|
|
61
51
|
* the horizontal coordinate within the application's client area at which the event occurred
|
|
62
|
-
* @type {number}
|
|
63
52
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX}
|
|
64
53
|
*/
|
|
65
54
|
clientX: number;
|
|
66
55
|
/**
|
|
67
56
|
* the vertical coordinate within the application's client area at which the event occurred
|
|
68
|
-
* @type {number}
|
|
69
57
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY}
|
|
70
58
|
*/
|
|
71
59
|
clientY: number;
|
|
72
60
|
/**
|
|
73
61
|
* the difference in the X coordinate of the pointer since the previous move event
|
|
74
|
-
* @type {number}
|
|
75
62
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX}
|
|
76
63
|
*/
|
|
77
64
|
movementX: number;
|
|
78
65
|
/**
|
|
79
66
|
* the difference in the Y coordinate of the pointer since the previous move event
|
|
80
|
-
* @type {number}
|
|
81
67
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementY}
|
|
82
68
|
*/
|
|
83
69
|
movementY: number;
|
|
84
70
|
/**
|
|
85
71
|
* an unsigned long representing the unit of the delta values scroll amount
|
|
86
|
-
* @type {number}
|
|
87
72
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode}
|
|
88
73
|
*/
|
|
89
74
|
deltaMode: number;
|
|
90
75
|
/**
|
|
91
76
|
* a double representing the horizontal scroll amount in the Wheel Event deltaMode unit.
|
|
92
|
-
* @type {number}
|
|
93
77
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaX}
|
|
94
78
|
*/
|
|
95
79
|
deltaX: number;
|
|
96
80
|
/**
|
|
97
81
|
* a double representing the vertical scroll amount in the Wheel Event deltaMode unit.
|
|
98
|
-
* @type {number}
|
|
99
82
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaY}
|
|
100
83
|
*/
|
|
101
84
|
deltaY: number;
|
|
102
85
|
/**
|
|
103
86
|
* a double representing the scroll amount in the z-axis, in the Wheel Event deltaMode unit.
|
|
104
|
-
* @type {number}
|
|
105
87
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaZ}
|
|
106
88
|
*/
|
|
107
89
|
deltaZ: number;
|
|
108
90
|
/**
|
|
109
91
|
* Event normalized X coordinate within the game canvas itself<br>
|
|
110
92
|
* <img src="images/event_coord.png"/>
|
|
111
|
-
* @type {number}
|
|
112
93
|
*/
|
|
113
94
|
gameX: number;
|
|
114
95
|
/**
|
|
115
96
|
* Event normalized Y coordinate within the game canvas itself<br>
|
|
116
97
|
* <img src="images/event_coord.png"/>
|
|
117
|
-
* @type {number}
|
|
118
98
|
*/
|
|
119
99
|
gameY: number;
|
|
120
100
|
/**
|
|
121
101
|
* Event X coordinate relative to the viewport
|
|
122
|
-
* @type {number}
|
|
123
102
|
*/
|
|
124
103
|
gameScreenX: number;
|
|
125
104
|
/**
|
|
126
105
|
* Event Y coordinate relative to the viewport
|
|
127
|
-
* @type {number}
|
|
128
106
|
*/
|
|
129
107
|
gameScreenY: number;
|
|
130
108
|
/**
|
|
131
109
|
* Event X coordinate relative to the map
|
|
132
|
-
* @type {number}
|
|
133
110
|
*/
|
|
134
111
|
gameWorldX: number;
|
|
135
112
|
/**
|
|
136
113
|
* Event Y coordinate relative to the map
|
|
137
|
-
* @type {number}
|
|
138
114
|
*/
|
|
139
115
|
gameWorldY: number;
|
|
140
116
|
/**
|
|
141
117
|
* Event X coordinate relative to the holding container
|
|
142
|
-
* @type {number}
|
|
143
118
|
*/
|
|
144
119
|
gameLocalX: number;
|
|
145
120
|
/**
|
|
146
121
|
* Event Y coordinate relative to the holding container
|
|
147
|
-
* @type {number}
|
|
148
122
|
*/
|
|
149
123
|
gameLocalY: number;
|
|
150
124
|
/**
|
|
151
125
|
* The unique identifier of the contact for a touch, mouse or pen
|
|
152
|
-
* @type {number}
|
|
153
126
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId}
|
|
154
127
|
*/
|
|
155
|
-
pointerId: number;
|
|
128
|
+
pointerId: number | undefined;
|
|
156
129
|
/**
|
|
157
130
|
* true if not originally a pointer event
|
|
158
|
-
* @type {boolean}
|
|
159
131
|
*/
|
|
160
132
|
isNormalized: boolean;
|
|
161
133
|
/**
|
|
162
134
|
* true if the pointer is currently locked
|
|
163
|
-
* @type {boolean}
|
|
164
135
|
*/
|
|
165
136
|
locked: boolean;
|
|
166
|
-
bind: number[];
|
|
137
|
+
bind: (number | null)[];
|
|
138
|
+
/**
|
|
139
|
+
* @ignore
|
|
140
|
+
*/
|
|
141
|
+
constructor(x?: number, y?: number, w?: number, h?: number);
|
|
167
142
|
/**
|
|
168
143
|
* initialize the Pointer object using the given Event Object
|
|
169
|
-
* @
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
private setEvent;
|
|
144
|
+
* @param event - the original Event object
|
|
145
|
+
* @param pageX - the horizontal coordinate at which the event occurred, relative to the left edge of the entire document
|
|
146
|
+
* @param pageY - the vertical coordinate at which the event occurred, relative to the left edge of the entire document
|
|
147
|
+
* @param clientX - the horizontal coordinate within the application's client area at which the event occurred
|
|
148
|
+
* @param clientY - the vertical coordinate within the application's client area at which the event occurred
|
|
149
|
+
* @param pointerId - the Pointer, Touch or Mouse event Id (1)
|
|
150
|
+
*/
|
|
151
|
+
setEvent(event: Event, pageX?: number, pageY?: number, clientX?: number, clientY?: number, pointerId?: number): void;
|
|
178
152
|
}
|
|
179
|
-
|
|
153
|
+
export default Pointer;
|
|
180
154
|
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/input/pointer.
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/input/pointer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAUhD;;GAEG;AACH,cAAM,OAAQ,SAAQ,MAAM;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,KAAK,EAAE,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;IAE1D;;;OAGG;IACM,IAAI,EAAE,MAAM,CAAM;IAE3B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAGhB,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAExB;;OAEG;gBACS,CAAC,GAAE,MAAU,EAAE,CAAC,GAAE,MAAU,EAAE,CAAC,GAAE,MAAU,EAAE,CAAC,GAAE,MAAU;IAyCtE;;;;;;;;OAQG;IACH,QAAQ,CACP,KAAK,EAAE,KAAK,EACZ,KAAK,GAAE,MAAU,EACjB,KAAK,GAAE,MAAU,EACjB,OAAO,GAAE,MAAU,EACnB,OAAO,GAAE,MAAU,EACnB,SAAS,GAAE,MAAU,GACnB,IAAI;CAqEP;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -1,24 +1,41 @@
|
|
|
1
|
+
import type { Vector2d } from "../math/vector2d.ts";
|
|
2
|
+
import Pointer from "./pointer.ts";
|
|
3
|
+
/**
|
|
4
|
+
* the default target element for pointer events (usually the canvas element in which the game is rendered)
|
|
5
|
+
*/
|
|
6
|
+
export declare let pointerEventTarget: EventTarget | null;
|
|
7
|
+
/**
|
|
8
|
+
* Pointer information (current position and size)
|
|
9
|
+
*/
|
|
10
|
+
export declare const pointer: Pointer;
|
|
11
|
+
/**
|
|
12
|
+
* indicates if the pointer is currently locked
|
|
13
|
+
*/
|
|
14
|
+
export declare let locked: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* time interval for event throttling in milliseconds<br>
|
|
17
|
+
* default value : "1000/me.timer.maxfps" ms<br>
|
|
18
|
+
* set to 0 ms to disable the feature
|
|
19
|
+
*/
|
|
20
|
+
export declare let throttlingInterval: number | undefined;
|
|
1
21
|
/**
|
|
2
22
|
* return true if there are pending pointer events in the queue
|
|
3
|
-
* @memberof input
|
|
4
23
|
* @returns true if there are pending events
|
|
5
24
|
*/
|
|
6
|
-
export function hasActiveEvents(): boolean;
|
|
25
|
+
export declare function hasActiveEvents(): boolean;
|
|
7
26
|
/**
|
|
8
27
|
* return true if there are register pointer events
|
|
9
|
-
* @memberof input
|
|
10
28
|
* @see {@link registerPointerEvent}
|
|
11
29
|
* @returns true if there are pending events
|
|
12
30
|
*/
|
|
13
|
-
export function hasRegisteredEvents(): boolean;
|
|
31
|
+
export declare function hasRegisteredEvents(): boolean;
|
|
14
32
|
/**
|
|
15
33
|
* Translate the specified x and y values from the global (absolute)
|
|
16
34
|
* coordinate to local (viewport) relative coordinate.
|
|
17
|
-
* @
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @
|
|
21
|
-
* @returns {Vector2d} A vector object with the corresponding translated coordinates
|
|
35
|
+
* @param x - the global x coordinate to be translated.
|
|
36
|
+
* @param y - the global y coordinate to be translated.
|
|
37
|
+
* @param v - an optional vector object where to set the translated coordinates
|
|
38
|
+
* @returns A vector object with the corresponding translated coordinates
|
|
22
39
|
* @example
|
|
23
40
|
* onMouseEvent : function (pointer) {
|
|
24
41
|
* // convert the given into local (viewport) relative coordinates
|
|
@@ -26,24 +43,21 @@ export function hasRegisteredEvents(): boolean;
|
|
|
26
43
|
* // do something with pos !
|
|
27
44
|
* };
|
|
28
45
|
*/
|
|
29
|
-
export function globalToLocal(x: number, y: number, v?: Vector2d): Vector2d;
|
|
46
|
+
export declare function globalToLocal(x: number, y: number, v?: Vector2d): Vector2d;
|
|
30
47
|
/**
|
|
31
48
|
* enable/disable all gestures on the given element.<br>
|
|
32
49
|
* by default melonJS will disable browser handling of all panning and zooming gestures.
|
|
33
|
-
* @memberof input
|
|
34
50
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action}
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
51
|
+
* @param element - the HTML element to configure
|
|
52
|
+
* @param value - the touch-action CSS value
|
|
37
53
|
*/
|
|
38
|
-
export function setTouchAction(element: HTMLCanvasElement, value?: string): void;
|
|
54
|
+
export declare function setTouchAction(element: HTMLCanvasElement, value?: string): void;
|
|
39
55
|
/**
|
|
40
56
|
* Associate a pointer event to a keycode<br>
|
|
41
|
-
* Left button
|
|
42
|
-
* Middle button
|
|
43
|
-
* Right button
|
|
44
|
-
* @
|
|
45
|
-
* @param {number} [button=input.pointer.LEFT] - (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
46
|
-
* @param {input.KEY} keyCode
|
|
57
|
+
* Left button -- 0
|
|
58
|
+
* Middle button -- 1
|
|
59
|
+
* Right button -- 2
|
|
60
|
+
* @param args - button and/or keyCode
|
|
47
61
|
* @example
|
|
48
62
|
* // enable the keyboard
|
|
49
63
|
* me.input.bindKey(me.input.KEY.X, "shoot");
|
|
@@ -52,22 +66,20 @@ export function setTouchAction(element: HTMLCanvasElement, value?: string): void
|
|
|
52
66
|
* // map the right button click on the X key
|
|
53
67
|
* me.input.bindPointer(me.input.pointer.RIGHT, me.input.KEY.X);
|
|
54
68
|
*/
|
|
55
|
-
export function bindPointer(...args:
|
|
69
|
+
export declare function bindPointer(...args: number[]): void;
|
|
56
70
|
/**
|
|
57
71
|
* unbind the defined keycode
|
|
58
|
-
* @
|
|
59
|
-
* @param {number} [button=input.pointer.LEFT] - (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
72
|
+
* @param button - (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
60
73
|
* @example
|
|
61
74
|
* me.input.unbindPointer(me.input.pointer.LEFT);
|
|
62
75
|
*/
|
|
63
|
-
export function unbindPointer(button?: number): void;
|
|
76
|
+
export declare function unbindPointer(button?: number): void;
|
|
64
77
|
/**
|
|
65
78
|
* allows registration of event listeners on the object target. <br>
|
|
66
79
|
* melonJS will pass a me.Pointer object to the defined callback.
|
|
67
80
|
* @see Pointer
|
|
68
81
|
* @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events | W3C Pointer Event list}
|
|
69
|
-
* @
|
|
70
|
-
* @param {string} eventType - The event type for which the object is registering <br>
|
|
82
|
+
* @param eventType - The event type for which the object is registering <br>
|
|
71
83
|
* melonJS currently supports: <br>
|
|
72
84
|
* <ul>
|
|
73
85
|
* <li><code>"pointermove"</code></li>
|
|
@@ -79,8 +91,8 @@ export function unbindPointer(button?: number): void;
|
|
|
79
91
|
* <li><code>"pointercancel"</code></li>
|
|
80
92
|
* <li><code>"wheel"</code></li>
|
|
81
93
|
* </ul>
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
94
|
+
* @param region - a shape representing the region to register on
|
|
95
|
+
* @param callback - methods to be called when the event occurs.
|
|
84
96
|
* Returning `false` from the defined callback will prevent the event to be propagated to other objects
|
|
85
97
|
* @example
|
|
86
98
|
* // onActivate function
|
|
@@ -97,33 +109,30 @@ export function unbindPointer(button?: number): void;
|
|
|
97
109
|
* return false;
|
|
98
110
|
* },
|
|
99
111
|
*/
|
|
100
|
-
export function registerPointerEvent(eventType: string, region:
|
|
112
|
+
export declare function registerPointerEvent(eventType: string, region: any, callback: (pointer: Pointer) => boolean | void): void;
|
|
101
113
|
/**
|
|
102
114
|
* allows the removal of event listeners from the object target.
|
|
103
115
|
* @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
|
|
104
|
-
* @
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
107
|
-
* @param {Function} [callback="all"] - if specified unregister the event only for the specific callback
|
|
116
|
+
* @param eventType - The event type for which the object was registered. See {@link input.registerPointerEvent}
|
|
117
|
+
* @param region - the registered region to release for this event
|
|
118
|
+
* @param callback - if specified unregister the event only for the specific callback
|
|
108
119
|
* @example
|
|
109
120
|
* // release the registered region on the 'pointerdown' event
|
|
110
121
|
* me.input.releasePointerEvent('pointerdown', this);
|
|
111
122
|
*/
|
|
112
|
-
export function releasePointerEvent(eventType: string, region:
|
|
123
|
+
export declare function releasePointerEvent(eventType: string, region: any, callback?: (pointer: Pointer) => boolean | void): void;
|
|
113
124
|
/**
|
|
114
125
|
* allows the removal of all registered event listeners from the object target.
|
|
115
|
-
* @
|
|
116
|
-
* @param {Rect|Polygon|Line|Ellipse} region - the registered region to release event from
|
|
126
|
+
* @param region - the registered region to release event from
|
|
117
127
|
* @example
|
|
118
128
|
* // release all registered event on the
|
|
119
129
|
* me.input.releaseAllPointerEvents(this);
|
|
120
130
|
*/
|
|
121
|
-
export function releaseAllPointerEvents(region:
|
|
131
|
+
export declare function releaseAllPointerEvents(region: any): void;
|
|
122
132
|
/**
|
|
123
133
|
* request for the pointer to be locked on the parent DOM element.
|
|
124
134
|
* (Must be called in a click event or an event that requires user interaction)
|
|
125
|
-
* @
|
|
126
|
-
* @returns {boolean} return true if the request was successfully submitted
|
|
135
|
+
* @returns return true if the request was successfully submitted
|
|
127
136
|
* @example
|
|
128
137
|
* // register on the pointer lock change event
|
|
129
138
|
* event.on(event.POINTERLOCKCHANGE, (locked)=> {
|
|
@@ -132,47 +141,10 @@ export function releaseAllPointerEvents(region: Rect | Polygon | Line | Ellipse)
|
|
|
132
141
|
* // request for pointer lock
|
|
133
142
|
* me.input.requestPointerLock();
|
|
134
143
|
*/
|
|
135
|
-
export function requestPointerLock(): boolean;
|
|
144
|
+
export declare function requestPointerLock(): boolean;
|
|
136
145
|
/**
|
|
137
146
|
* Initiates an exit from pointer lock state
|
|
138
|
-
* @
|
|
139
|
-
* @returns {boolean} return true if the request was successfully submitted
|
|
140
|
-
*/
|
|
141
|
-
export function exitPointerLock(): boolean;
|
|
142
|
-
/**
|
|
143
|
-
* the default target element for pointer events (usually the canvas element in which the game is rendered)
|
|
144
|
-
* @public
|
|
145
|
-
* @type {EventTarget}
|
|
146
|
-
* @name pointerEventTarget
|
|
147
|
-
* @memberof input
|
|
148
|
-
*/
|
|
149
|
-
export let pointerEventTarget: EventTarget;
|
|
150
|
-
/**
|
|
151
|
-
* Pointer information (current position and size)
|
|
152
|
-
* @public
|
|
153
|
-
* @type {Rect}
|
|
154
|
-
* @name pointer
|
|
155
|
-
* @memberof input
|
|
156
|
-
*/
|
|
157
|
-
export const pointer: Rect;
|
|
158
|
-
/**
|
|
159
|
-
* indicates if the pointer is currently locked
|
|
160
|
-
* @public
|
|
161
|
-
* @type {boolean}
|
|
162
|
-
* @name locked
|
|
163
|
-
* @memberof input
|
|
164
|
-
*/
|
|
165
|
-
export let locked: boolean;
|
|
166
|
-
/**
|
|
167
|
-
* time interval for event throttling in milliseconds<br>
|
|
168
|
-
* default value : "1000/me.timer.maxfps" ms<br>
|
|
169
|
-
* set to 0 ms to disable the feature
|
|
170
|
-
* @public
|
|
171
|
-
* @type {number}
|
|
172
|
-
* @name throttlingInterval
|
|
173
|
-
* @memberof input
|
|
147
|
+
* @returns return true if the request was successfully submitted
|
|
174
148
|
*/
|
|
175
|
-
export
|
|
176
|
-
import type { Vector2d } from "../math/vector2d.js";
|
|
177
|
-
import { Rect } from "./../geometries/rectangle.ts";
|
|
149
|
+
export declare function exitPointerLock(): boolean;
|
|
178
150
|
//# sourceMappingURL=pointerevent.d.ts.map
|