melonjs 10.2.0 → 10.3.0
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/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
|
@@ -5,13 +5,12 @@ import Polygon from "./poly.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a rectangle Object
|
|
7
7
|
* @class Rect
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {Number} h height of the rectangle
|
|
8
|
+
* @augments me.Polygon
|
|
9
|
+
* @memberof me
|
|
10
|
+
* @param {number} x position of the Rectangle
|
|
11
|
+
* @param {number} y position of the Rectangle
|
|
12
|
+
* @param {number} w width of the rectangle
|
|
13
|
+
* @param {number} h height of the rectangle
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
16
|
class Rect extends Polygon {
|
|
@@ -35,13 +34,13 @@ class Rect extends Polygon {
|
|
|
35
34
|
/**
|
|
36
35
|
* set new value to the rectangle shape
|
|
37
36
|
* @name setShape
|
|
38
|
-
* @
|
|
37
|
+
* @memberof me.Rect.prototype
|
|
39
38
|
* @function
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
44
|
-
* @
|
|
39
|
+
* @param {number} x position of the Rectangle
|
|
40
|
+
* @param {number} y position of the Rectangle
|
|
41
|
+
* @param {number|me.Vector2d[]} w width of the rectangle, or an array of vector defining the rectangle
|
|
42
|
+
* @param {number} [h] height of the rectangle, if a numeral width parameter is specified
|
|
43
|
+
* @returns {me.Rect} this rectangle
|
|
45
44
|
*/
|
|
46
45
|
setShape(x, y, w, h) {
|
|
47
46
|
var points = w; // assume w is an array by default
|
|
@@ -64,13 +63,9 @@ class Rect extends Polygon {
|
|
|
64
63
|
/**
|
|
65
64
|
* left coordinate of the Rectangle
|
|
66
65
|
* @public
|
|
67
|
-
* @type {
|
|
66
|
+
* @type {number}
|
|
68
67
|
* @name left
|
|
69
|
-
* @
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @ignore
|
|
68
|
+
* @memberof me.Rect
|
|
74
69
|
*/
|
|
75
70
|
get left() {
|
|
76
71
|
return this.pos.x;
|
|
@@ -79,13 +74,9 @@ class Rect extends Polygon {
|
|
|
79
74
|
/**
|
|
80
75
|
* right coordinate of the Rectangle
|
|
81
76
|
* @public
|
|
82
|
-
* @type {
|
|
77
|
+
* @type {number}
|
|
83
78
|
* @name right
|
|
84
|
-
* @
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @ignore
|
|
79
|
+
* @memberof me.Rect
|
|
89
80
|
*/
|
|
90
81
|
get right() {
|
|
91
82
|
var w = this.width;
|
|
@@ -95,13 +86,9 @@ class Rect extends Polygon {
|
|
|
95
86
|
/**
|
|
96
87
|
* top coordinate of the Rectangle
|
|
97
88
|
* @public
|
|
98
|
-
* @type {
|
|
89
|
+
* @type {number}
|
|
99
90
|
* @name top
|
|
100
|
-
* @
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @ignore
|
|
91
|
+
* @memberof me.Rect
|
|
105
92
|
*/
|
|
106
93
|
get top() {
|
|
107
94
|
return this.pos.y;
|
|
@@ -110,13 +97,9 @@ class Rect extends Polygon {
|
|
|
110
97
|
/**
|
|
111
98
|
* bottom coordinate of the Rectangle
|
|
112
99
|
* @public
|
|
113
|
-
* @type {
|
|
100
|
+
* @type {number}
|
|
114
101
|
* @name bottom
|
|
115
|
-
* @
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @ignore
|
|
102
|
+
* @memberof me.Rect
|
|
120
103
|
*/
|
|
121
104
|
get bottom() {
|
|
122
105
|
var h = this.height;
|
|
@@ -126,20 +109,13 @@ class Rect extends Polygon {
|
|
|
126
109
|
/**
|
|
127
110
|
* width of the Rectangle
|
|
128
111
|
* @public
|
|
129
|
-
* @type {
|
|
112
|
+
* @type {number}
|
|
130
113
|
* @name width
|
|
131
|
-
* @
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @ignore
|
|
114
|
+
* @memberof me.Rect
|
|
136
115
|
*/
|
|
137
116
|
get width() {
|
|
138
117
|
return this.points[2].x;
|
|
139
118
|
}
|
|
140
|
-
/**
|
|
141
|
-
* @ignore
|
|
142
|
-
*/
|
|
143
119
|
set width(value) {
|
|
144
120
|
this.points[1].x = this.points[2].x = value;
|
|
145
121
|
this.recalc();
|
|
@@ -149,20 +125,13 @@ class Rect extends Polygon {
|
|
|
149
125
|
/**
|
|
150
126
|
* height of the Rectangle
|
|
151
127
|
* @public
|
|
152
|
-
* @type {
|
|
128
|
+
* @type {number}
|
|
153
129
|
* @name height
|
|
154
|
-
* @
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @ignore
|
|
130
|
+
* @memberof me.Rect
|
|
159
131
|
*/
|
|
160
132
|
get height() {
|
|
161
133
|
return this.points[2].y;
|
|
162
134
|
}
|
|
163
|
-
/**
|
|
164
|
-
* @ignore
|
|
165
|
-
*/
|
|
166
135
|
set height(value) {
|
|
167
136
|
this.points[2].y = this.points[3].y = value;
|
|
168
137
|
this.recalc();
|
|
@@ -172,13 +141,9 @@ class Rect extends Polygon {
|
|
|
172
141
|
/**
|
|
173
142
|
* absolute center of this rectangle on the horizontal axis
|
|
174
143
|
* @public
|
|
175
|
-
* @type {
|
|
144
|
+
* @type {number}
|
|
176
145
|
* @name centerX
|
|
177
|
-
* @
|
|
178
|
-
*/
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @ignore
|
|
146
|
+
* @memberof me.Rect
|
|
182
147
|
*/
|
|
183
148
|
get centerX() {
|
|
184
149
|
if (isFinite(this.width)) {
|
|
@@ -187,10 +152,6 @@ class Rect extends Polygon {
|
|
|
187
152
|
return this.width;
|
|
188
153
|
}
|
|
189
154
|
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @ignore
|
|
193
|
-
*/
|
|
194
155
|
set centerX (value) {
|
|
195
156
|
this.pos.x = value - (this.width / 2);
|
|
196
157
|
}
|
|
@@ -198,13 +159,9 @@ class Rect extends Polygon {
|
|
|
198
159
|
/**
|
|
199
160
|
* absolute center of this rectangle on the vertical axis
|
|
200
161
|
* @public
|
|
201
|
-
* @type {
|
|
162
|
+
* @type {number}
|
|
202
163
|
* @name centerY
|
|
203
|
-
* @
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* @ignore
|
|
164
|
+
* @memberof me.Rect
|
|
208
165
|
*/
|
|
209
166
|
get centerY() {
|
|
210
167
|
if (isFinite(this.height)) {
|
|
@@ -213,10 +170,6 @@ class Rect extends Polygon {
|
|
|
213
170
|
return this.height;
|
|
214
171
|
}
|
|
215
172
|
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @ignore
|
|
219
|
-
*/
|
|
220
173
|
set centerY(value) {
|
|
221
174
|
this.pos.y = value - (this.height / 2);
|
|
222
175
|
}
|
|
@@ -224,11 +177,11 @@ class Rect extends Polygon {
|
|
|
224
177
|
/**
|
|
225
178
|
* resize the rectangle
|
|
226
179
|
* @name resize
|
|
227
|
-
* @
|
|
180
|
+
* @memberof me.Rect.prototype
|
|
228
181
|
* @function
|
|
229
|
-
* @param {
|
|
230
|
-
* @param {
|
|
231
|
-
* @
|
|
182
|
+
* @param {number} w new width of the rectangle
|
|
183
|
+
* @param {number} h new height of the rectangle
|
|
184
|
+
* @returns {me.Rect} this rectangle
|
|
232
185
|
*/
|
|
233
186
|
resize(w, h) {
|
|
234
187
|
this.width = w;
|
|
@@ -239,11 +192,11 @@ class Rect extends Polygon {
|
|
|
239
192
|
/**
|
|
240
193
|
* scale the rectangle
|
|
241
194
|
* @name scale
|
|
242
|
-
* @
|
|
195
|
+
* @memberof me.Rect.prototype
|
|
243
196
|
* @function
|
|
244
|
-
* @param {
|
|
245
|
-
* @param {
|
|
246
|
-
* @
|
|
197
|
+
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
198
|
+
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
199
|
+
* @returns {me.Rect} this rectangle
|
|
247
200
|
*/
|
|
248
201
|
scale(x, y = x) {
|
|
249
202
|
this.width *= x;
|
|
@@ -254,9 +207,9 @@ class Rect extends Polygon {
|
|
|
254
207
|
/**
|
|
255
208
|
* clone this rectangle
|
|
256
209
|
* @name clone
|
|
257
|
-
* @
|
|
210
|
+
* @memberof me.Rect.prototype
|
|
258
211
|
* @function
|
|
259
|
-
* @
|
|
212
|
+
* @returns {me.Rect} new rectangle
|
|
260
213
|
*/
|
|
261
214
|
clone() {
|
|
262
215
|
return new Rect(this.pos.x, this.pos.y, this.width, this.height);
|
|
@@ -265,10 +218,10 @@ class Rect extends Polygon {
|
|
|
265
218
|
/**
|
|
266
219
|
* copy the position and size of the given rectangle into this one
|
|
267
220
|
* @name copy
|
|
268
|
-
* @
|
|
221
|
+
* @memberof me.Rect.prototype
|
|
269
222
|
* @function
|
|
270
223
|
* @param {me.Rect} rect Source rectangle
|
|
271
|
-
* @
|
|
224
|
+
* @returns {me.Rect} new rectangle
|
|
272
225
|
*/
|
|
273
226
|
copy(rect) {
|
|
274
227
|
return this.setShape(rect.pos.x, rect.pos.y, rect.width, rect.height);
|
|
@@ -277,18 +230,18 @@ class Rect extends Polygon {
|
|
|
277
230
|
/**
|
|
278
231
|
* merge this rectangle with another one
|
|
279
232
|
* @name union
|
|
280
|
-
* @
|
|
233
|
+
* @memberof me.Rect.prototype
|
|
281
234
|
* @function
|
|
282
235
|
* @param {me.Rect} rect other rectangle to union with
|
|
283
|
-
* @
|
|
236
|
+
* @returns {me.Rect} the union(ed) rectangle
|
|
284
237
|
*/
|
|
285
|
-
union(
|
|
286
|
-
var x1 = Math.min(this.left,
|
|
287
|
-
var y1 = Math.min(this.top,
|
|
238
|
+
union(rect) {
|
|
239
|
+
var x1 = Math.min(this.left, rect.left);
|
|
240
|
+
var y1 = Math.min(this.top, rect.top);
|
|
288
241
|
|
|
289
242
|
this.resize(
|
|
290
|
-
Math.max(this.right,
|
|
291
|
-
Math.max(this.bottom,
|
|
243
|
+
Math.max(this.right, rect.right) - x1,
|
|
244
|
+
Math.max(this.bottom, rect.bottom) - y1
|
|
292
245
|
);
|
|
293
246
|
|
|
294
247
|
this.pos.set(x1, y1);
|
|
@@ -299,46 +252,46 @@ class Rect extends Polygon {
|
|
|
299
252
|
/**
|
|
300
253
|
* check if this rectangle is intersecting with the specified one
|
|
301
254
|
* @name overlaps
|
|
302
|
-
* @
|
|
255
|
+
* @memberof me.Rect.prototype
|
|
303
256
|
* @function
|
|
304
257
|
* @param {me.Rect} rect
|
|
305
|
-
* @
|
|
258
|
+
* @returns {boolean} true if overlaps
|
|
306
259
|
*/
|
|
307
|
-
overlaps(
|
|
260
|
+
overlaps(rect) {
|
|
308
261
|
return (
|
|
309
|
-
this.left <
|
|
310
|
-
|
|
311
|
-
this.top <
|
|
312
|
-
|
|
262
|
+
this.left < rect.right &&
|
|
263
|
+
rect.left < this.right &&
|
|
264
|
+
this.top < rect.bottom &&
|
|
265
|
+
rect.top < this.bottom
|
|
313
266
|
);
|
|
314
267
|
}
|
|
315
268
|
|
|
316
269
|
/**
|
|
317
270
|
* Returns true if the rectangle contains the given rectangle
|
|
318
271
|
* @name contains
|
|
319
|
-
* @
|
|
272
|
+
* @memberof me.Rect.prototype
|
|
320
273
|
* @function
|
|
321
274
|
* @param {me.Rect} rect
|
|
322
|
-
* @
|
|
275
|
+
* @returns {boolean} true if contains
|
|
323
276
|
*/
|
|
324
277
|
|
|
325
278
|
/**
|
|
326
279
|
* Returns true if the rectangle contains the given point
|
|
327
280
|
* @name contains
|
|
328
|
-
* @
|
|
281
|
+
* @memberof me.Rect.prototype
|
|
329
282
|
* @function
|
|
330
|
-
* @param {
|
|
331
|
-
* @param {
|
|
332
|
-
* @
|
|
283
|
+
* @param {number} x x coordinate
|
|
284
|
+
* @param {number} y y coordinate
|
|
285
|
+
* @returns {boolean} true if contains
|
|
333
286
|
*/
|
|
334
287
|
|
|
335
288
|
/**
|
|
336
289
|
* Returns true if the rectangle contains the given point
|
|
337
290
|
* @name contains
|
|
338
|
-
* @
|
|
291
|
+
* @memberof me.Rect
|
|
339
292
|
* @function
|
|
340
293
|
* @param {me.Vector2d} point
|
|
341
|
-
* @
|
|
294
|
+
* @returns {boolean} true if contains
|
|
342
295
|
*/
|
|
343
296
|
contains() {
|
|
344
297
|
var arg0 = arguments[0];
|
|
@@ -371,26 +324,26 @@ class Rect extends Polygon {
|
|
|
371
324
|
/**
|
|
372
325
|
* check if this rectangle is identical to the specified one
|
|
373
326
|
* @name equals
|
|
374
|
-
* @
|
|
327
|
+
* @memberof me.Rect.prototype
|
|
375
328
|
* @function
|
|
376
329
|
* @param {me.Rect} rect
|
|
377
|
-
* @
|
|
330
|
+
* @returns {boolean} true if equals
|
|
378
331
|
*/
|
|
379
|
-
equals(
|
|
332
|
+
equals(rect) {
|
|
380
333
|
return (
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
334
|
+
rect.left === this.left &&
|
|
335
|
+
rect.right === this.right &&
|
|
336
|
+
rect.top === this.top &&
|
|
337
|
+
rect.bottom === this.bottom
|
|
385
338
|
);
|
|
386
339
|
}
|
|
387
340
|
|
|
388
341
|
/**
|
|
389
342
|
* determines whether all coordinates of this rectangle are finite numbers.
|
|
390
343
|
* @name isFinite
|
|
391
|
-
* @
|
|
344
|
+
* @memberof me.Rect.prototype
|
|
392
345
|
* @function
|
|
393
|
-
* @
|
|
346
|
+
* @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
394
347
|
*/
|
|
395
348
|
isFinite() {
|
|
396
349
|
return (isFinite(this.pos.x) && isFinite(this.pos.y) && isFinite(this.width) && isFinite(this.height));
|
|
@@ -399,9 +352,9 @@ class Rect extends Polygon {
|
|
|
399
352
|
/**
|
|
400
353
|
* Returns a polygon whose edges are the same as this box.
|
|
401
354
|
* @name toPolygon
|
|
402
|
-
* @
|
|
355
|
+
* @memberof me.Rect.prototype
|
|
403
356
|
* @function
|
|
404
|
-
* @
|
|
357
|
+
* @returns {me.Polygon} a new Polygon that represents this rectangle.
|
|
405
358
|
*/
|
|
406
359
|
toPolygon() {
|
|
407
360
|
return new Polygon(
|
package/src/index.js
CHANGED
|
@@ -28,10 +28,10 @@ import ObservableVector2d from "./math/observable_vector2.js";
|
|
|
28
28
|
import ObservableVector3d from "./math/observable_vector3.js";
|
|
29
29
|
import Matrix2d from "./math/matrix2.js";
|
|
30
30
|
import Matrix3d from "./math/matrix3.js";
|
|
31
|
-
import Polygon from "./
|
|
32
|
-
import Line from "./
|
|
33
|
-
import Ellipse from "./
|
|
34
|
-
import Rect from "./
|
|
31
|
+
import Polygon from "./geometries/poly.js";
|
|
32
|
+
import Line from "./geometries/line.js";
|
|
33
|
+
import Ellipse from "./geometries/ellipse.js";
|
|
34
|
+
import Rect from "./geometries/rectangle.js";
|
|
35
35
|
import QuadTree from "./physics/quadtree.js";
|
|
36
36
|
import Body from "./physics/body.js";
|
|
37
37
|
import Bounds from "./physics/bounds.js";
|
|
@@ -79,10 +79,10 @@ import DroptargetEntity from "./entity/droptarget.js";
|
|
|
79
79
|
import * as deprecated from "./lang/deprecated.js";
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* (<b>m</b>)elonJS (<b>e</b>)ngine : All melonJS functions are defined inside this namespace.
|
|
83
|
-
* You generally should not add new properties to this namespace as it may be overwritten in future versions.
|
|
84
|
-
* @namespace me
|
|
85
|
-
*/
|
|
82
|
+
* (<b>m</b>)elonJS (<b>e</b>)ngine : All melonJS functions are defined inside this namespace.
|
|
83
|
+
* You generally should not add new properties to this namespace as it may be overwritten in future versions.
|
|
84
|
+
* @namespace me
|
|
85
|
+
*/
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* current melonJS version
|
|
@@ -173,28 +173,27 @@ export {
|
|
|
173
173
|
DroptargetEntity
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
// Backward compatibility for deprecated method or properties
|
|
177
|
-
// automatically applied when generating the UMD module through rollup
|
|
176
|
+
// Backward compatibility for deprecated method or properties
|
|
178
177
|
export {
|
|
179
178
|
deprecated
|
|
180
179
|
};
|
|
181
180
|
|
|
182
181
|
|
|
183
182
|
/**
|
|
184
|
-
* a flag indicating that melonJS is fully initialized
|
|
185
|
-
* @type {
|
|
186
|
-
* @default false
|
|
187
|
-
* @readonly
|
|
188
|
-
* @
|
|
189
|
-
*/
|
|
183
|
+
* a flag indicating that melonJS is fully initialized
|
|
184
|
+
* @type {boolean}
|
|
185
|
+
* @default false
|
|
186
|
+
* @readonly
|
|
187
|
+
* @memberof me
|
|
188
|
+
*/
|
|
190
189
|
export var initialized = false;
|
|
191
190
|
|
|
192
191
|
/**
|
|
193
192
|
* disable melonJS auto-initialization
|
|
194
|
-
* @type {
|
|
193
|
+
* @type {boolean}
|
|
195
194
|
* @default false
|
|
196
195
|
* @see me.boot
|
|
197
|
-
* @
|
|
196
|
+
* @memberof me
|
|
198
197
|
*/
|
|
199
198
|
export var skipAutoInit = false;
|
|
200
199
|
|
|
@@ -203,7 +202,7 @@ export var skipAutoInit = false;
|
|
|
203
202
|
* this is automatically called unless me.skipAutoInit is set to true,
|
|
204
203
|
* to allow asynchronous loaders to work.
|
|
205
204
|
* @name boot
|
|
206
|
-
* @
|
|
205
|
+
* @memberof me
|
|
207
206
|
* @see me.skipAutoInit
|
|
208
207
|
* @public
|
|
209
208
|
* @function
|
package/src/input/gamepad.js
CHANGED
|
@@ -284,7 +284,7 @@ window.addEventListener("gamepaddisconnected", function (e) {
|
|
|
284
284
|
* Namespace for standard gamepad mapping constants
|
|
285
285
|
* @public
|
|
286
286
|
* @namespace GAMEPAD
|
|
287
|
-
* @
|
|
287
|
+
* @memberof me.input
|
|
288
288
|
*/
|
|
289
289
|
export var GAMEPAD = {
|
|
290
290
|
/**
|
|
@@ -296,8 +296,8 @@ export var GAMEPAD = {
|
|
|
296
296
|
* </ul>
|
|
297
297
|
* @public
|
|
298
298
|
* @name AXES
|
|
299
|
-
* @enum {
|
|
300
|
-
* @
|
|
299
|
+
* @enum {number}
|
|
300
|
+
* @memberof me.input.GAMEPAD
|
|
301
301
|
* @see https://w3c.github.io/gamepad/#remapping
|
|
302
302
|
*/
|
|
303
303
|
"AXES" : {
|
|
@@ -323,8 +323,8 @@ export var GAMEPAD = {
|
|
|
323
323
|
* </ul>
|
|
324
324
|
* @public
|
|
325
325
|
* @name BUTTONS
|
|
326
|
-
* @enum {
|
|
327
|
-
* @
|
|
326
|
+
* @enum {number}
|
|
327
|
+
* @memberof me.input.GAMEPAD
|
|
328
328
|
* @see https://w3c.github.io/gamepad/#remapping
|
|
329
329
|
*/
|
|
330
330
|
"BUTTONS" : {
|
|
@@ -357,14 +357,14 @@ export var GAMEPAD = {
|
|
|
357
357
|
/**
|
|
358
358
|
* Associate a gamepad event to a keycode
|
|
359
359
|
* @name bindGamepad
|
|
360
|
-
* @
|
|
360
|
+
* @memberof me.input
|
|
361
361
|
* @public
|
|
362
362
|
* @function
|
|
363
|
-
* @param {
|
|
364
|
-
* @param {
|
|
365
|
-
* @param {
|
|
363
|
+
* @param {number} index Gamepad index
|
|
364
|
+
* @param {object} button Button/Axis definition
|
|
365
|
+
* @param {string} button.type "buttons" or "axes"
|
|
366
366
|
* @param {me.input.GAMEPAD.BUTTONS|me.input.GAMEPAD.AXES} button.code button or axis code id
|
|
367
|
-
* @param {
|
|
367
|
+
* @param {number} [button.threshold=1] value indicating when the axis should trigger the keycode (e.g. -0.5 or 0.5)
|
|
368
368
|
* @param {me.input.KEY} keyCode
|
|
369
369
|
* @example
|
|
370
370
|
* // enable the keyboard
|
|
@@ -432,10 +432,10 @@ export function bindGamepad(index, button, keyCode) {
|
|
|
432
432
|
/**
|
|
433
433
|
* unbind the defined keycode
|
|
434
434
|
* @name unbindGamepad
|
|
435
|
-
* @
|
|
435
|
+
* @memberof me.input
|
|
436
436
|
* @public
|
|
437
437
|
* @function
|
|
438
|
-
* @param {
|
|
438
|
+
* @param {number} index Gamepad index
|
|
439
439
|
* @param {me.input.GAMEPAD.BUTTONS} button
|
|
440
440
|
* @example
|
|
441
441
|
* me.input.unbindGamepad(0, me.input.GAMEPAD.BUTTONS.FACE_1);
|
|
@@ -451,10 +451,10 @@ export function unbindGamepad(index, button) {
|
|
|
451
451
|
* Set deadzone for analog gamepad inputs<br>
|
|
452
452
|
* The default deadzone is 0.1 (10%) Analog values less than this will be ignored
|
|
453
453
|
* @name setGamepadDeadzone
|
|
454
|
-
* @
|
|
454
|
+
* @memberof me.input
|
|
455
455
|
* @public
|
|
456
456
|
* @function
|
|
457
|
-
* @param {
|
|
457
|
+
* @param {number} value Deadzone value
|
|
458
458
|
*/
|
|
459
459
|
export function setGamepadDeadzone(value) {
|
|
460
460
|
deadzone = value;
|
|
@@ -465,14 +465,14 @@ export function setGamepadDeadzone(value) {
|
|
|
465
465
|
* see below for the default mapping : <br>
|
|
466
466
|
* <center><img src="images/gamepad_diagram.png"/></center><br>
|
|
467
467
|
* @name setGamepadMapping
|
|
468
|
-
* @
|
|
468
|
+
* @memberof me.input
|
|
469
469
|
* @public
|
|
470
470
|
* @function
|
|
471
|
-
* @param {
|
|
472
|
-
* @param {
|
|
473
|
-
* @param {
|
|
474
|
-
* @param {
|
|
475
|
-
* @param {
|
|
471
|
+
* @param {string} id Gamepad id string
|
|
472
|
+
* @param {object} mapping A hash table
|
|
473
|
+
* @param {number[]} mapping.axes Standard analog control stick axis locations
|
|
474
|
+
* @param {number[]} mapping.buttons Standard digital button locations
|
|
475
|
+
* @param {number[]} [mapping.analog] Analog axis locations for buttons
|
|
476
476
|
* @param {Function} [mapping.normalize_fn] a function that returns a normalized value in range [-1.0..1.0] for the given value, axis and button
|
|
477
477
|
* @example
|
|
478
478
|
* // A weird controller that has its axis mappings reversed
|
package/src/input/input.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @namespace me.input
|
|
3
|
-
* @
|
|
3
|
+
* @memberof me
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* specify if melonJS should prevent all default browser action on registered events.
|
|
8
8
|
* @public
|
|
9
|
-
* @type
|
|
9
|
+
* @type {boolean}
|
|
10
10
|
* @default true
|
|
11
11
|
* @name preventDefault
|
|
12
|
-
* @
|
|
12
|
+
* @memberof me.input
|
|
13
13
|
*/
|
|
14
14
|
export var preventDefault = true;
|
|
15
15
|
|