melonjs 10.2.1 → 10.2.2
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 +2735 -2760
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2186 -2162
- package/dist/melonjs.module.js +2323 -2362
- package/package.json +8 -9
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +2 -2
- package/src/index.js +11 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +18 -26
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +29 -25
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +44 -44
- package/src/physics/bounds.js +34 -34
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -10
- package/src/physics/quadtree.js +19 -17
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +13 -13
- package/src/renderable/renderable.js +68 -66
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +6 -6
- package/src/state/state.js +54 -54
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +39 -41
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +74 -75
- package/src/video/video.js +30 -30
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +33 -34
- package/src/video/webgl/webgl_renderer.js +104 -104
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {preventDefault} from "./input.js";
|
|
2
2
|
import {getBindingKey, triggerKeyEvent} from "./keyboard.js";
|
|
3
|
-
import Vector2d from "./../math/vector2.js";
|
|
4
3
|
import { renderer, scaleRatio } from "./../video/video.js";
|
|
5
4
|
import * as fctUtil from "./../utils/function.js";
|
|
6
5
|
import * as arrayUtil from "./../utils/array.js";
|
|
@@ -11,13 +10,11 @@ import device from "./../system/device.js";
|
|
|
11
10
|
import Pointer from "./pointer.js";
|
|
12
11
|
import Rect from "./../shapes/rectangle.js";
|
|
13
12
|
import Container from "./../renderable/container.js";
|
|
14
|
-
import Renderable from "./../renderable/renderable.js";
|
|
15
13
|
import { world, viewport } from "./../game.js";
|
|
16
14
|
|
|
17
|
-
|
|
18
15
|
/**
|
|
19
16
|
* A pool of `Pointer` objects to cache pointer/touch event coordinates.
|
|
20
|
-
* @type {Array.<
|
|
17
|
+
* @type {Array.<me.Vector2d>}
|
|
21
18
|
* @ignore
|
|
22
19
|
*/
|
|
23
20
|
var T_POINTERS = [];
|
|
@@ -292,7 +289,7 @@ function dispatchEvent(normalizedEvents) {
|
|
|
292
289
|
var bounds = region.getBounds();
|
|
293
290
|
var eventInBounds = false;
|
|
294
291
|
|
|
295
|
-
if (region.
|
|
292
|
+
if (region.isFloating === true) {
|
|
296
293
|
pointer.gameX = pointer.gameLocalX = pointer.gameScreenX;
|
|
297
294
|
pointer.gameY = pointer.gameLocalY = pointer.gameScreenY;
|
|
298
295
|
} else {
|
|
@@ -308,10 +305,11 @@ function dispatchEvent(normalizedEvents) {
|
|
|
308
305
|
pointer.gameLocalY = pointer.gameY - parentBounds.y;
|
|
309
306
|
}
|
|
310
307
|
|
|
308
|
+
var gameX = pointer.gameX;
|
|
309
|
+
var gameY = pointer.gameY;
|
|
310
|
+
|
|
311
311
|
// apply inverse transformation for renderable
|
|
312
|
-
if (region
|
|
313
|
-
var gameX = pointer.gameX;
|
|
314
|
-
var gameY = pointer.gameY;
|
|
312
|
+
if (typeof region.currentTransform !== "undefined") {
|
|
315
313
|
if (!region.currentTransform.isIdentity()) {
|
|
316
314
|
var invV = region.currentTransform.applyInverse(
|
|
317
315
|
pool.pull("Vector2d", gameX, gameY)
|
|
@@ -320,14 +318,8 @@ function dispatchEvent(normalizedEvents) {
|
|
|
320
318
|
gameY = invV.y;
|
|
321
319
|
pool.push(invV);
|
|
322
320
|
}
|
|
323
|
-
eventInBounds = bounds.contains(gameX, gameY);
|
|
324
|
-
} else {
|
|
325
|
-
eventInBounds =
|
|
326
|
-
bounds.contains(pointer.gameX, pointer.gameY) &&
|
|
327
|
-
(bounds === region ||
|
|
328
|
-
// if the given target is another shape than me.Rect
|
|
329
|
-
region.contains(pointer.gameLocalX, pointer.gameLocalY));
|
|
330
321
|
}
|
|
322
|
+
eventInBounds = bounds.contains(gameX, gameY);
|
|
331
323
|
|
|
332
324
|
switch (pointer.type) {
|
|
333
325
|
case POINTER_MOVE[0]:
|
|
@@ -498,7 +490,7 @@ function onPointerEvent(e) {
|
|
|
498
490
|
/**
|
|
499
491
|
* the default target element for pointer events (usually the canvas element in which the game is rendered)
|
|
500
492
|
* @public
|
|
501
|
-
* @type EventTarget
|
|
493
|
+
* @type {EventTarget}
|
|
502
494
|
* @name pointerEventTarget
|
|
503
495
|
* @memberOf me.input
|
|
504
496
|
*/
|
|
@@ -518,7 +510,7 @@ export var pointer = new Pointer(0, 0, 1, 1);
|
|
|
518
510
|
* default value : "1000/me.timer.maxfps" ms<br>
|
|
519
511
|
* set to 0 ms to disable the feature
|
|
520
512
|
* @public
|
|
521
|
-
* @type
|
|
513
|
+
* @type {number}
|
|
522
514
|
* @name throttlingInterval
|
|
523
515
|
* @memberOf me.input
|
|
524
516
|
*/
|
|
@@ -531,10 +523,10 @@ export var throttlingInterval;
|
|
|
531
523
|
* @memberOf me.input
|
|
532
524
|
* @public
|
|
533
525
|
* @function
|
|
534
|
-
* @param {
|
|
535
|
-
* @param {
|
|
526
|
+
* @param {number} x the global x coordinate to be translated.
|
|
527
|
+
* @param {number} y the global y coordinate to be translated.
|
|
536
528
|
* @param {me.Vector2d} [v] an optional vector object where to set the translated coordinates
|
|
537
|
-
* @
|
|
529
|
+
* @returns {me.Vector2d} A vector object with the corresponding translated coordinates
|
|
538
530
|
* @example
|
|
539
531
|
* onMouseEvent : function (pointer) {
|
|
540
532
|
* // convert the given into local (viewport) relative coordinates
|
|
@@ -543,7 +535,7 @@ export var throttlingInterval;
|
|
|
543
535
|
* };
|
|
544
536
|
*/
|
|
545
537
|
export function globalToLocal(x, y, v) {
|
|
546
|
-
v = v ||
|
|
538
|
+
v = v || pool.pull("Vector2d");
|
|
547
539
|
var rect = device.getElementBounds(renderer.getScreenCanvas());
|
|
548
540
|
var pixelRatio = device.devicePixelRatio;
|
|
549
541
|
x -= rect.left + (window.pageXOffset || 0);
|
|
@@ -565,7 +557,7 @@ export function globalToLocal(x, y, v) {
|
|
|
565
557
|
* @public
|
|
566
558
|
* @function
|
|
567
559
|
* @param {HTMLCanvasElement} element
|
|
568
|
-
* @param {
|
|
560
|
+
* @param {string} [value="none"]
|
|
569
561
|
*/
|
|
570
562
|
export function setTouchAction(element, value) {
|
|
571
563
|
element.style["touch-action"] = value || "none";
|
|
@@ -580,7 +572,7 @@ export function setTouchAction(element, value) {
|
|
|
580
572
|
* @memberOf me.input
|
|
581
573
|
* @public
|
|
582
574
|
* @function
|
|
583
|
-
* @param {
|
|
575
|
+
* @param {number} [button=me.input.pointer.LEFT] (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
584
576
|
* @param {me.input.KEY} keyCode
|
|
585
577
|
* @example
|
|
586
578
|
* // enable the keyboard
|
|
@@ -611,7 +603,7 @@ export function bindPointer() {
|
|
|
611
603
|
* @memberOf me.input
|
|
612
604
|
* @public
|
|
613
605
|
* @function
|
|
614
|
-
* @param {
|
|
606
|
+
* @param {number} [button=me.input.pointer.LEFT] (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
615
607
|
* @example
|
|
616
608
|
* me.input.unbindPointer(me.input.pointer.LEFT);
|
|
617
609
|
*/
|
|
@@ -633,7 +625,7 @@ export function unbindPointer(button) {
|
|
|
633
625
|
* @memberOf me.input
|
|
634
626
|
* @public
|
|
635
627
|
* @function
|
|
636
|
-
* @param {
|
|
628
|
+
* @param {string} eventType The event type for which the object is registering <br>
|
|
637
629
|
* melonJS currently supports: <br>
|
|
638
630
|
* <ul>
|
|
639
631
|
* <li><code>"pointermove"</code></li>
|
|
@@ -705,7 +697,7 @@ export function registerPointerEvent(eventType, region, callback) {
|
|
|
705
697
|
* @memberOf me.input
|
|
706
698
|
* @public
|
|
707
699
|
* @function
|
|
708
|
-
* @param {
|
|
700
|
+
* @param {string} eventType The event type for which the object was registered. See {@link me.input.registerPointerEvent}
|
|
709
701
|
* @param {me.Rect|me.Polygon|me.Line|me.Ellipse} region the registered region to release for this event
|
|
710
702
|
* @param {Function} [callback="all"] if specified unregister the event only for the specific callback
|
|
711
703
|
* @example
|
package/src/lang/deprecated.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* @function
|
|
11
11
|
* @memberOf me.deprecated
|
|
12
12
|
* @name warning
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {string} deprecated deprecated class,function or property name
|
|
14
|
+
* @param {string} replacement the replacement class, function, or property name
|
|
15
|
+
* @param {string} version the version since when the lass,function or property is deprecated
|
|
16
16
|
*/
|
|
17
17
|
export function warning(deprecated, replacement, version) {
|
|
18
18
|
var msg = "melonJS: %s is deprecated since version %s, please use %s";
|
package/src/level/level.js
CHANGED
|
@@ -13,6 +13,9 @@ var levelIdx = [];
|
|
|
13
13
|
// current level index
|
|
14
14
|
var currentLevelIdx = 0;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @ignore
|
|
18
|
+
*/
|
|
16
19
|
function safeLoadLevel(levelId, options, restart) {
|
|
17
20
|
// clean the destination container
|
|
18
21
|
options.container.reset();
|
|
@@ -48,8 +51,8 @@ function safeLoadLevel(levelId, options, restart) {
|
|
|
48
51
|
* @name loadTMXLevel
|
|
49
52
|
* @memberOf me.level
|
|
50
53
|
* @private
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {me.Container} target container
|
|
54
|
+
* @param {string} levelId level id
|
|
55
|
+
* @param {me.Container} container target container
|
|
53
56
|
* @param {boolean} [flatten=true] if true, flatten all objects into the given container
|
|
54
57
|
* @param {boolean} [setViewportBounds=false] if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
55
58
|
* @ignore
|
|
@@ -84,10 +87,10 @@ var level = {
|
|
|
84
87
|
* @memberOf me.level
|
|
85
88
|
* @public
|
|
86
89
|
* @function
|
|
87
|
-
* @param {
|
|
88
|
-
* @param {
|
|
90
|
+
* @param {string} format level format (only "tmx" supported)
|
|
91
|
+
* @param {string} levelId the level id (or name)
|
|
89
92
|
* @param {Function} [callback] a function to be called once the level is loaded
|
|
90
|
-
* @
|
|
93
|
+
* @returns {boolean} true if the level was loaded
|
|
91
94
|
*/
|
|
92
95
|
add(format, levelId, callback) {
|
|
93
96
|
switch (format) {
|
|
@@ -123,12 +126,13 @@ var level = {
|
|
|
123
126
|
* @memberOf me.level
|
|
124
127
|
* @public
|
|
125
128
|
* @function
|
|
126
|
-
* @param {
|
|
127
|
-
* @param {
|
|
129
|
+
* @param {string} levelId level id
|
|
130
|
+
* @param {object} [options] additional optional parameters
|
|
128
131
|
* @param {me.Container} [options.container=me.game.world] container in which to load the specified level
|
|
129
|
-
* @param {
|
|
132
|
+
* @param {Function} [options.onLoaded=me.game.onLevelLoaded] callback for when the level is fully loaded
|
|
130
133
|
* @param {boolean} [options.flatten=me.game.mergeGroup] if true, flatten all objects into the given container
|
|
131
134
|
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
135
|
+
* @returns {boolean} true if the level was successfully loaded
|
|
132
136
|
* @example
|
|
133
137
|
* // the game assets to be be preloaded
|
|
134
138
|
* // TMX maps
|
|
@@ -196,7 +200,7 @@ var level = {
|
|
|
196
200
|
* @memberOf me.level
|
|
197
201
|
* @public
|
|
198
202
|
* @function
|
|
199
|
-
* @
|
|
203
|
+
* @returns {string}
|
|
200
204
|
*/
|
|
201
205
|
getCurrentLevelId() {
|
|
202
206
|
return levelIdx[currentLevelIdx];
|
|
@@ -210,7 +214,7 @@ var level = {
|
|
|
210
214
|
* @memberOf me.level
|
|
211
215
|
* @public
|
|
212
216
|
* @function
|
|
213
|
-
* @
|
|
217
|
+
* @returns {me.TMXTileMap}
|
|
214
218
|
*/
|
|
215
219
|
getCurrentLevel() {
|
|
216
220
|
return levels[this.getCurrentLevelId()];
|
|
@@ -222,10 +226,11 @@ var level = {
|
|
|
222
226
|
* @memberOf me.level
|
|
223
227
|
* @public
|
|
224
228
|
* @function
|
|
225
|
-
* @param {
|
|
229
|
+
* @param {object} [options] additional optional parameters
|
|
226
230
|
* @param {me.Container} [options.container=me.game.world] container in which to load the specified level
|
|
227
|
-
* @param {
|
|
231
|
+
* @param {Function} [options.onLoaded=me.game.onLevelLoaded] callback for when the level is fully loaded
|
|
228
232
|
* @param {boolean} [options.flatten=me.game.mergeGroup] if true, flatten all objects into the given container
|
|
233
|
+
* @returns {object} the current level
|
|
229
234
|
*/
|
|
230
235
|
reload(options) {
|
|
231
236
|
// reset the level to initial state
|
|
@@ -239,10 +244,11 @@ var level = {
|
|
|
239
244
|
* @memberOf me.level
|
|
240
245
|
* @public
|
|
241
246
|
* @function
|
|
242
|
-
* @param {
|
|
247
|
+
* @param {object} [options] additional optional parameters
|
|
243
248
|
* @param {me.Container} [options.container=me.game.world] container in which to load the specified level
|
|
244
|
-
* @param {
|
|
249
|
+
* @param {Function} [options.onLoaded=me.game.onLevelLoaded] callback for when the level is fully loaded
|
|
245
250
|
* @param {boolean} [options.flatten=me.game.mergeGroup] if true, flatten all objects into the given container
|
|
251
|
+
* @returns {boolean} true if the next level was successfully loaded
|
|
246
252
|
*/
|
|
247
253
|
next(options) {
|
|
248
254
|
//go to the next level
|
|
@@ -260,10 +266,11 @@ var level = {
|
|
|
260
266
|
* @memberOf me.level
|
|
261
267
|
* @public
|
|
262
268
|
* @function
|
|
263
|
-
* @param {
|
|
269
|
+
* @param {object} [options] additional optional parameters
|
|
264
270
|
* @param {me.Container} [options.container=me.game.world] container in which to load the specified level
|
|
265
|
-
* @param {
|
|
271
|
+
* @param {Function} [options.onLoaded=me.game.onLevelLoaded] callback for when the level is fully loaded
|
|
266
272
|
* @param {boolean} [options.flatten=me.game.mergeGroup] if true, flatten all objects into the given container
|
|
273
|
+
* @returns {boolean} true if the previous level was successfully loaded
|
|
267
274
|
*/
|
|
268
275
|
previous(options) {
|
|
269
276
|
// go to previous level
|
|
@@ -281,6 +288,7 @@ var level = {
|
|
|
281
288
|
* @memberOf me.level
|
|
282
289
|
* @public
|
|
283
290
|
* @function
|
|
291
|
+
* @returns {number} the amount of level preloaded
|
|
284
292
|
*/
|
|
285
293
|
levelCount() {
|
|
286
294
|
return levelIdx.length;
|
|
@@ -18,7 +18,7 @@ export default class TMXGroup {
|
|
|
18
18
|
/**
|
|
19
19
|
* group name
|
|
20
20
|
* @public
|
|
21
|
-
* @type
|
|
21
|
+
* @type {string}
|
|
22
22
|
* @name name
|
|
23
23
|
* @memberOf me.TMXGroup
|
|
24
24
|
*/
|
|
@@ -27,7 +27,7 @@ export default class TMXGroup {
|
|
|
27
27
|
/**
|
|
28
28
|
* group width
|
|
29
29
|
* @public
|
|
30
|
-
* @type
|
|
30
|
+
* @type {number}
|
|
31
31
|
* @name width
|
|
32
32
|
* @memberOf me.TMXGroup
|
|
33
33
|
*/
|
|
@@ -36,7 +36,7 @@ export default class TMXGroup {
|
|
|
36
36
|
/**
|
|
37
37
|
* group height
|
|
38
38
|
* @public
|
|
39
|
-
* @type
|
|
39
|
+
* @type {number}
|
|
40
40
|
* @name height
|
|
41
41
|
* @memberOf me.TMXGroup
|
|
42
42
|
*/
|
|
@@ -45,7 +45,7 @@ export default class TMXGroup {
|
|
|
45
45
|
/**
|
|
46
46
|
* tint color
|
|
47
47
|
* @public
|
|
48
|
-
* @type
|
|
48
|
+
* @type {string}
|
|
49
49
|
* @name tintcolor
|
|
50
50
|
* @memberOf me.TMXGroup
|
|
51
51
|
*/
|
|
@@ -54,7 +54,7 @@ export default class TMXGroup {
|
|
|
54
54
|
/**
|
|
55
55
|
* group z order
|
|
56
56
|
* @public
|
|
57
|
-
* @type
|
|
57
|
+
* @type {number}
|
|
58
58
|
* @name z
|
|
59
59
|
* @memberOf me.TMXGroup
|
|
60
60
|
*/
|
|
@@ -64,7 +64,7 @@ export default class TMXGroup {
|
|
|
64
64
|
* group objects list definition
|
|
65
65
|
* @see me.TMXObject
|
|
66
66
|
* @public
|
|
67
|
-
* @type
|
|
67
|
+
* @type {object[]}
|
|
68
68
|
* @name name
|
|
69
69
|
* @memberOf me.TMXGroup
|
|
70
70
|
*/
|
|
@@ -69,13 +69,13 @@ function preRenderLayer(layer, renderer) {
|
|
|
69
69
|
* @extends me.Renderable
|
|
70
70
|
* @memberOf me
|
|
71
71
|
* @constructor
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {
|
|
72
|
+
* @param {object} map layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
73
|
+
* @param {object} data layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
74
|
+
* @param {number} tilewidth width of each tile in pixels
|
|
75
|
+
* @param {number} tileheight height of each tile in pixels
|
|
76
|
+
* @param {string} orientation "isometric" or "orthogonal"
|
|
77
77
|
* @param {me.TMXTilesetGroup} tilesets tileset as defined in Tiled
|
|
78
|
-
* @param {
|
|
78
|
+
* @param {number} z z-index position
|
|
79
79
|
*/
|
|
80
80
|
class TMXLayer extends Renderable {
|
|
81
81
|
/**
|
|
@@ -95,7 +95,7 @@ class TMXLayer extends Renderable {
|
|
|
95
95
|
/**
|
|
96
96
|
* The Layer corresponding Tilesets
|
|
97
97
|
* @public
|
|
98
|
-
* @type me.TMXTilesetGroup
|
|
98
|
+
* @type {me.TMXTilesetGroup}
|
|
99
99
|
* @name me.TMXLayer#tilesets
|
|
100
100
|
*/
|
|
101
101
|
this.tilesets = tilesets;
|
|
@@ -118,7 +118,7 @@ class TMXLayer extends Renderable {
|
|
|
118
118
|
/**
|
|
119
119
|
* All animated tilesets in this layer
|
|
120
120
|
* @ignore
|
|
121
|
-
* @type
|
|
121
|
+
* @type {me.TMXTileset[]}
|
|
122
122
|
* @name me.TMXLayer#animatedTilesets
|
|
123
123
|
*/
|
|
124
124
|
this.animatedTilesets = [];
|
|
@@ -126,7 +126,7 @@ class TMXLayer extends Renderable {
|
|
|
126
126
|
/**
|
|
127
127
|
* Layer contains tileset animations
|
|
128
128
|
* @public
|
|
129
|
-
* @type
|
|
129
|
+
* @type {boolean}
|
|
130
130
|
* @name me.TMXLayer#isAnimated
|
|
131
131
|
*/
|
|
132
132
|
this.isAnimated = false;
|
|
@@ -135,7 +135,7 @@ class TMXLayer extends Renderable {
|
|
|
135
135
|
* the order in which tiles on orthogonal tile layers are rendered.
|
|
136
136
|
* (valid values are "left-down", "left-up", "right-down", "right-up")
|
|
137
137
|
* @public
|
|
138
|
-
* @type {
|
|
138
|
+
* @type {string}
|
|
139
139
|
* @default "right-down"
|
|
140
140
|
* @name me.TMXLayer#renderorder
|
|
141
141
|
*/
|
|
@@ -262,7 +262,7 @@ class TMXLayer extends Renderable {
|
|
|
262
262
|
* @memberOf me.TMXLayer
|
|
263
263
|
* @public
|
|
264
264
|
* @function
|
|
265
|
-
* @
|
|
265
|
+
* @returns {me.TMXRenderer} renderer
|
|
266
266
|
*/
|
|
267
267
|
getRenderer() {
|
|
268
268
|
return this.renderer;
|
|
@@ -275,9 +275,9 @@ class TMXLayer extends Renderable {
|
|
|
275
275
|
* @memberOf me.TMXLayer
|
|
276
276
|
* @public
|
|
277
277
|
* @function
|
|
278
|
-
* @param {
|
|
279
|
-
* @param {
|
|
280
|
-
* @
|
|
278
|
+
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
279
|
+
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
280
|
+
* @returns {number} TileId or null if there is no Tile at the given position
|
|
281
281
|
*/
|
|
282
282
|
getTileId(x, y) {
|
|
283
283
|
var tile = this.getTile(x, y);
|
|
@@ -290,9 +290,9 @@ class TMXLayer extends Renderable {
|
|
|
290
290
|
* @memberOf me.TMXLayer
|
|
291
291
|
* @public
|
|
292
292
|
* @function
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {
|
|
295
|
-
* @
|
|
293
|
+
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
294
|
+
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
295
|
+
* @returns {me.Tile} corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds
|
|
296
296
|
* @example
|
|
297
297
|
* // get the TMX Map Layer called "Front layer"
|
|
298
298
|
* var layer = me.game.world.getChildByName("Front Layer")[0];
|
|
@@ -316,10 +316,10 @@ class TMXLayer extends Renderable {
|
|
|
316
316
|
* @memberOf me.TMXLayer
|
|
317
317
|
* @public
|
|
318
318
|
* @function
|
|
319
|
-
* @
|
|
320
|
-
* @param {
|
|
321
|
-
* @param {
|
|
322
|
-
* @
|
|
319
|
+
* @param {me.Tile} tile the tile object to be assigned
|
|
320
|
+
* @param {number} x x coordinate (in world/pixels coordinates)
|
|
321
|
+
* @param {number} y y coordinate (in world/pixels coordinates)
|
|
322
|
+
* @returns {me.Tile} the tile object
|
|
323
323
|
*/
|
|
324
324
|
setTile(tile, x, y) {
|
|
325
325
|
this.layerData[x][y] = tile;
|
|
@@ -332,10 +332,10 @@ class TMXLayer extends Renderable {
|
|
|
332
332
|
* @memberOf me.TMXLayer
|
|
333
333
|
* @public
|
|
334
334
|
* @function
|
|
335
|
-
* @param {
|
|
336
|
-
* @param {
|
|
337
|
-
* @param {
|
|
338
|
-
* @
|
|
335
|
+
* @param {number} tileId tileId
|
|
336
|
+
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
337
|
+
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
338
|
+
* @returns {me.Tile} the tile object
|
|
339
339
|
*/
|
|
340
340
|
getTileById(tileId, x, y) {
|
|
341
341
|
if (!this.tileset.contains(tileId)) {
|
|
@@ -351,10 +351,10 @@ class TMXLayer extends Renderable {
|
|
|
351
351
|
* @memberOf me.TMXLayer
|
|
352
352
|
* @public
|
|
353
353
|
* @function
|
|
354
|
-
* @param {
|
|
355
|
-
* @param {
|
|
356
|
-
* @param {
|
|
357
|
-
* @
|
|
354
|
+
* @param {number} x x position of the tile (in Tile unit)
|
|
355
|
+
* @param {number} y x position of the tile (in Tile unit)
|
|
356
|
+
* @param {number} [boundsCheck=true] check first if within the layer bounds
|
|
357
|
+
* @returns {me.Tile} corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds
|
|
358
358
|
* @example
|
|
359
359
|
* // return the first tile at offset 0, 0
|
|
360
360
|
* var tile = layer.cellAt(0, 0);
|
|
@@ -378,8 +378,8 @@ class TMXLayer extends Renderable {
|
|
|
378
378
|
* @memberOf me.TMXLayer
|
|
379
379
|
* @public
|
|
380
380
|
* @function
|
|
381
|
-
* @param {
|
|
382
|
-
* @param {
|
|
381
|
+
* @param {number} x X coordinate (in map coordinates: row/column)
|
|
382
|
+
* @param {number} y Y coordinate (in map coordinates: row/column)
|
|
383
383
|
* @example
|
|
384
384
|
* me.game.world.getChildByType(me.TMXLayer).forEach(function(layer) {
|
|
385
385
|
* // clear all tiles at the given x,y coordinates
|
|
@@ -20,7 +20,7 @@ export default class TMXObject {
|
|
|
20
20
|
/**
|
|
21
21
|
* point list in JSON format
|
|
22
22
|
* @public
|
|
23
|
-
* @type
|
|
23
|
+
* @type {object[]}
|
|
24
24
|
* @name points
|
|
25
25
|
* @memberOf me.TMXObject
|
|
26
26
|
*/
|
|
@@ -29,7 +29,7 @@ export default class TMXObject {
|
|
|
29
29
|
/**
|
|
30
30
|
* object name
|
|
31
31
|
* @public
|
|
32
|
-
* @type
|
|
32
|
+
* @type {string}
|
|
33
33
|
* @name name
|
|
34
34
|
* @memberOf me.TMXObject
|
|
35
35
|
*/
|
|
@@ -38,7 +38,7 @@ export default class TMXObject {
|
|
|
38
38
|
/**
|
|
39
39
|
* object x position
|
|
40
40
|
* @public
|
|
41
|
-
* @type
|
|
41
|
+
* @type {number}
|
|
42
42
|
* @name x
|
|
43
43
|
* @memberOf me.TMXObject
|
|
44
44
|
*/
|
|
@@ -47,7 +47,7 @@ export default class TMXObject {
|
|
|
47
47
|
/**
|
|
48
48
|
* object y position
|
|
49
49
|
* @public
|
|
50
|
-
* @type
|
|
50
|
+
* @type {number}
|
|
51
51
|
* @name y
|
|
52
52
|
* @memberOf me.TMXObject
|
|
53
53
|
*/
|
|
@@ -56,7 +56,7 @@ export default class TMXObject {
|
|
|
56
56
|
/**
|
|
57
57
|
* object z order
|
|
58
58
|
* @public
|
|
59
|
-
* @type
|
|
59
|
+
* @type {number}
|
|
60
60
|
* @name z
|
|
61
61
|
* @memberOf me.TMXObject
|
|
62
62
|
*/
|
|
@@ -65,7 +65,7 @@ export default class TMXObject {
|
|
|
65
65
|
/**
|
|
66
66
|
* object width
|
|
67
67
|
* @public
|
|
68
|
-
* @type
|
|
68
|
+
* @type {number}
|
|
69
69
|
* @name width
|
|
70
70
|
* @memberOf me.TMXObject
|
|
71
71
|
*/
|
|
@@ -74,7 +74,7 @@ export default class TMXObject {
|
|
|
74
74
|
/**
|
|
75
75
|
* object height
|
|
76
76
|
* @public
|
|
77
|
-
* @type
|
|
77
|
+
* @type {number}
|
|
78
78
|
* @name height
|
|
79
79
|
* @memberOf me.TMXObject
|
|
80
80
|
*/
|
|
@@ -84,7 +84,7 @@ export default class TMXObject {
|
|
|
84
84
|
* object gid value
|
|
85
85
|
* when defined the object is a tiled object
|
|
86
86
|
* @public
|
|
87
|
-
* @type
|
|
87
|
+
* @type {number}
|
|
88
88
|
* @name gid
|
|
89
89
|
* @memberOf me.TMXObject
|
|
90
90
|
*/
|
|
@@ -93,7 +93,7 @@ export default class TMXObject {
|
|
|
93
93
|
/**
|
|
94
94
|
* tint color
|
|
95
95
|
* @public
|
|
96
|
-
* @type
|
|
96
|
+
* @type {string}
|
|
97
97
|
* @name tintcolor
|
|
98
98
|
* @memberOf me.TMXObject
|
|
99
99
|
*/
|
|
@@ -102,7 +102,7 @@ export default class TMXObject {
|
|
|
102
102
|
/**
|
|
103
103
|
* object type
|
|
104
104
|
* @public
|
|
105
|
-
* @type
|
|
105
|
+
* @type {string}
|
|
106
106
|
* @name type
|
|
107
107
|
* @memberOf me.TMXObject
|
|
108
108
|
*/
|
|
@@ -111,7 +111,7 @@ export default class TMXObject {
|
|
|
111
111
|
/**
|
|
112
112
|
* object text
|
|
113
113
|
* @public
|
|
114
|
-
* @type
|
|
114
|
+
* @type {object}
|
|
115
115
|
* @see http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#text
|
|
116
116
|
* @name type
|
|
117
117
|
* @memberOf me.TMXObject
|
|
@@ -121,7 +121,7 @@ export default class TMXObject {
|
|
|
121
121
|
/**
|
|
122
122
|
* The rotation of the object in radians clockwise (defaults to 0)
|
|
123
123
|
* @public
|
|
124
|
-
* @type
|
|
124
|
+
* @type {number}
|
|
125
125
|
* @name rotation
|
|
126
126
|
* @memberOf me.TMXObject
|
|
127
127
|
*/
|
|
@@ -130,7 +130,7 @@ export default class TMXObject {
|
|
|
130
130
|
/**
|
|
131
131
|
* object unique identifier per level (Tiled 0.11.x+)
|
|
132
132
|
* @public
|
|
133
|
-
* @type
|
|
133
|
+
* @type {number}
|
|
134
134
|
* @name id
|
|
135
135
|
* @memberOf me.TMXObject
|
|
136
136
|
*/
|
|
@@ -139,7 +139,7 @@ export default class TMXObject {
|
|
|
139
139
|
/**
|
|
140
140
|
* object orientation (orthogonal or isometric)
|
|
141
141
|
* @public
|
|
142
|
-
* @type
|
|
142
|
+
* @type {string}
|
|
143
143
|
* @name orientation
|
|
144
144
|
* @memberOf me.TMXObject
|
|
145
145
|
*/
|
|
@@ -148,7 +148,7 @@ export default class TMXObject {
|
|
|
148
148
|
/**
|
|
149
149
|
* the collision shapes defined for this object
|
|
150
150
|
* @public
|
|
151
|
-
* @type
|
|
151
|
+
* @type {object[]}
|
|
152
152
|
* @name shapes
|
|
153
153
|
* @memberOf me.TMXObject
|
|
154
154
|
*/
|
|
@@ -157,7 +157,7 @@ export default class TMXObject {
|
|
|
157
157
|
/**
|
|
158
158
|
* if true, the object is an Ellipse
|
|
159
159
|
* @public
|
|
160
|
-
* @type
|
|
160
|
+
* @type {boolean}
|
|
161
161
|
* @name isEllipse
|
|
162
162
|
* @memberOf me.TMXObject
|
|
163
163
|
*/
|
|
@@ -166,7 +166,7 @@ export default class TMXObject {
|
|
|
166
166
|
/**
|
|
167
167
|
* if true, the object is a Polygon
|
|
168
168
|
* @public
|
|
169
|
-
* @type
|
|
169
|
+
* @type {boolean}
|
|
170
170
|
* @name isPolygon
|
|
171
171
|
* @memberOf me.TMXObject
|
|
172
172
|
*/
|
|
@@ -175,7 +175,7 @@ export default class TMXObject {
|
|
|
175
175
|
/**
|
|
176
176
|
* if true, the object is a PolyLine
|
|
177
177
|
* @public
|
|
178
|
-
* @type
|
|
178
|
+
* @type {boolean}
|
|
179
179
|
* @name isPolyLine
|
|
180
180
|
* @memberOf me.TMXObject
|
|
181
181
|
*/
|
|
@@ -252,7 +252,7 @@ export default class TMXObject {
|
|
|
252
252
|
* @memberOf me.TMXObject
|
|
253
253
|
* @private
|
|
254
254
|
* @function
|
|
255
|
-
* @
|
|
255
|
+
* @returns {me.Polygon[]|me.Line[]|me.Ellipse[]} an array of shape objects
|
|
256
256
|
*/
|
|
257
257
|
parseTMXShapes() {
|
|
258
258
|
var i = 0;
|