melonjs 10.3.0 → 10.4.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 +6 -6
- package/dist/melonjs.js +2419 -3072
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +3417 -3816
- package/dist/melonjs.module.js +2737 -3002
- package/package.json +16 -16
- package/src/audio/audio.js +29 -30
- package/src/camera/camera2d.js +46 -56
- package/src/entity/draggable.js +12 -13
- package/src/entity/droptarget.js +13 -15
- package/src/entity/entity.js +30 -36
- package/src/game.js +21 -22
- package/src/geometries/ellipse.js +40 -46
- package/src/geometries/line.js +9 -11
- package/src/geometries/poly.js +53 -53
- package/src/geometries/rectangle.js +42 -44
- package/src/index.js +4 -14
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +30 -31
- package/src/input/pointerevent.js +26 -26
- package/src/lang/deprecated.js +25 -6
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -8
- package/src/level/tiled/TMXLayer.js +30 -32
- package/src/level/tiled/TMXObject.js +21 -21
- package/src/level/tiled/TMXTile.js +18 -18
- package/src/level/tiled/TMXTileMap.js +37 -44
- package/src/level/tiled/TMXTileset.js +12 -15
- package/src/level/tiled/TMXTilesetGroup.js +9 -9
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
- package/src/level/tiled/renderer/TMXRenderer.js +24 -25
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
- package/src/loader/loader.js +14 -15
- package/src/loader/loadingscreen.js +2 -4
- package/src/math/color.js +47 -66
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -58
- package/src/math/matrix3.js +56 -62
- package/src/math/observable_vector2.js +75 -76
- package/src/math/observable_vector3.js +79 -80
- package/src/math/vector2.js +91 -92
- package/src/math/vector3.js +94 -96
- package/src/particles/emitter.js +38 -40
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +44 -142
- package/src/physics/bounds.js +47 -47
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +17 -19
- package/src/physics/sat.js +26 -26
- package/src/physics/world.js +24 -28
- package/src/plugin/plugin.js +11 -14
- package/src/renderable/GUI.js +41 -46
- package/src/renderable/collectable.js +4 -8
- package/src/renderable/colorlayer.js +6 -10
- package/src/renderable/container.js +87 -72
- package/src/renderable/imagelayer.js +25 -31
- package/src/renderable/nineslicesprite.js +41 -41
- package/src/renderable/renderable.js +112 -122
- package/src/renderable/sprite.js +62 -68
- package/src/renderable/trigger.js +25 -30
- package/src/state/stage.js +13 -17
- package/src/state/state.js +26 -27
- package/src/system/device.js +74 -75
- package/src/system/event.js +71 -72
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -54
- package/src/text/bitmaptextdata.js +10 -10
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +44 -49
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +43 -44
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +58 -59
- package/src/video/renderer.js +49 -53
- package/src/video/texture.js +98 -111
- package/src/video/texture_cache.js +2 -2
- package/src/video/video.js +15 -16
- package/src/video/webgl/glshader.js +37 -38
- package/src/video/webgl/webgl_compositor.js +31 -32
- package/src/video/webgl/webgl_renderer.js +79 -80
|
@@ -14,7 +14,7 @@ import { world, viewport } from "./../game.js";
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* A pool of `Pointer` objects to cache pointer/touch event coordinates.
|
|
17
|
-
* @type {Array.<
|
|
17
|
+
* @type {Array.<Vector2d>}
|
|
18
18
|
* @ignore
|
|
19
19
|
*/
|
|
20
20
|
var T_POINTERS = [];
|
|
@@ -503,16 +503,16 @@ function onPointerEvent(e) {
|
|
|
503
503
|
* @public
|
|
504
504
|
* @type {EventTarget}
|
|
505
505
|
* @name pointerEventTarget
|
|
506
|
-
* @memberof
|
|
506
|
+
* @memberof input
|
|
507
507
|
*/
|
|
508
508
|
export var pointerEventTarget = null;
|
|
509
509
|
|
|
510
510
|
/**
|
|
511
511
|
* Pointer information (current position and size)
|
|
512
512
|
* @public
|
|
513
|
-
* @type {
|
|
513
|
+
* @type {Rect}
|
|
514
514
|
* @name pointer
|
|
515
|
-
* @memberof
|
|
515
|
+
* @memberof input
|
|
516
516
|
*/
|
|
517
517
|
export var pointer = new Pointer(0, 0, 1, 1);
|
|
518
518
|
|
|
@@ -522,7 +522,7 @@ export var pointer = new Pointer(0, 0, 1, 1);
|
|
|
522
522
|
* @public
|
|
523
523
|
* @type {boolean}
|
|
524
524
|
* @name locked
|
|
525
|
-
* @memberof
|
|
525
|
+
* @memberof input
|
|
526
526
|
*/
|
|
527
527
|
export var locked = false;
|
|
528
528
|
|
|
@@ -533,7 +533,7 @@ export var locked = false;
|
|
|
533
533
|
* @public
|
|
534
534
|
* @type {number}
|
|
535
535
|
* @name throttlingInterval
|
|
536
|
-
* @memberof
|
|
536
|
+
* @memberof input
|
|
537
537
|
*/
|
|
538
538
|
export var throttlingInterval;
|
|
539
539
|
|
|
@@ -541,13 +541,13 @@ export var throttlingInterval;
|
|
|
541
541
|
* Translate the specified x and y values from the global (absolute)
|
|
542
542
|
* coordinate to local (viewport) relative coordinate.
|
|
543
543
|
* @name globalToLocal
|
|
544
|
-
* @memberof
|
|
544
|
+
* @memberof input
|
|
545
545
|
* @public
|
|
546
546
|
* @function
|
|
547
547
|
* @param {number} x the global x coordinate to be translated.
|
|
548
548
|
* @param {number} y the global y coordinate to be translated.
|
|
549
|
-
* @param {
|
|
550
|
-
* @returns {
|
|
549
|
+
* @param {Vector2d} [v] an optional vector object where to set the translated coordinates
|
|
550
|
+
* @returns {Vector2d} A vector object with the corresponding translated coordinates
|
|
551
551
|
* @example
|
|
552
552
|
* onMouseEvent : function (pointer) {
|
|
553
553
|
* // convert the given into local (viewport) relative coordinates
|
|
@@ -573,7 +573,7 @@ export function globalToLocal(x, y, v) {
|
|
|
573
573
|
* enable/disable all gestures on the given element.<br>
|
|
574
574
|
* by default melonJS will disable browser handling of all panning and zooming gestures.
|
|
575
575
|
* @name setTouchAction
|
|
576
|
-
* @memberof
|
|
576
|
+
* @memberof input
|
|
577
577
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action
|
|
578
578
|
* @public
|
|
579
579
|
* @function
|
|
@@ -590,11 +590,11 @@ export function setTouchAction(element, value) {
|
|
|
590
590
|
* Middle button – 1
|
|
591
591
|
* Right button – 2
|
|
592
592
|
* @name bindPointer
|
|
593
|
-
* @memberof
|
|
593
|
+
* @memberof input
|
|
594
594
|
* @public
|
|
595
595
|
* @function
|
|
596
|
-
* @param {number} [button=
|
|
597
|
-
* @param {
|
|
596
|
+
* @param {number} [button=input.pointer.LEFT] (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
597
|
+
* @param {input.KEY} keyCode
|
|
598
598
|
* @example
|
|
599
599
|
* // enable the keyboard
|
|
600
600
|
* me.input.bindKey(me.input.KEY.X, "shoot");
|
|
@@ -621,10 +621,10 @@ export function bindPointer() {
|
|
|
621
621
|
/**
|
|
622
622
|
* unbind the defined keycode
|
|
623
623
|
* @name unbindPointer
|
|
624
|
-
* @memberof
|
|
624
|
+
* @memberof input
|
|
625
625
|
* @public
|
|
626
626
|
* @function
|
|
627
|
-
* @param {number} [button=
|
|
627
|
+
* @param {number} [button=input.pointer.LEFT] (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
628
628
|
* @example
|
|
629
629
|
* me.input.unbindPointer(me.input.pointer.LEFT);
|
|
630
630
|
*/
|
|
@@ -640,10 +640,10 @@ export function unbindPointer(button) {
|
|
|
640
640
|
/**
|
|
641
641
|
* allows registration of event listeners on the object target. <br>
|
|
642
642
|
* melonJS will pass a me.Pointer object to the defined callback.
|
|
643
|
-
* @see
|
|
643
|
+
* @see Pointer
|
|
644
644
|
* @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
|
|
645
645
|
* @name registerPointerEvent
|
|
646
|
-
* @memberof
|
|
646
|
+
* @memberof input
|
|
647
647
|
* @public
|
|
648
648
|
* @function
|
|
649
649
|
* @param {string} eventType The event type for which the object is registering <br>
|
|
@@ -658,7 +658,7 @@ export function unbindPointer(button) {
|
|
|
658
658
|
* <li><code>"pointercancel"</code></li>
|
|
659
659
|
* <li><code>"wheel"</code></li>
|
|
660
660
|
* </ul>
|
|
661
|
-
* @param {
|
|
661
|
+
* @param {Rect|Polygon|Line|Ellipse} region a shape representing the region to register on
|
|
662
662
|
* @param {Function} callback methods to be called when the event occurs.
|
|
663
663
|
* Returning `false` from the defined callback will prevent the event to be propagated to other objects
|
|
664
664
|
* @example
|
|
@@ -715,11 +715,11 @@ export function registerPointerEvent(eventType, region, callback) {
|
|
|
715
715
|
* allows the removal of event listeners from the object target.
|
|
716
716
|
* @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
|
|
717
717
|
* @name releasePointerEvent
|
|
718
|
-
* @memberof
|
|
718
|
+
* @memberof input
|
|
719
719
|
* @public
|
|
720
720
|
* @function
|
|
721
|
-
* @param {string} eventType The event type for which the object was registered. See {@link
|
|
722
|
-
* @param {
|
|
721
|
+
* @param {string} eventType The event type for which the object was registered. See {@link input.registerPointerEvent}
|
|
722
|
+
* @param {Rect|Polygon|Line|Ellipse} region the registered region to release for this event
|
|
723
723
|
* @param {Function} [callback="all"] if specified unregister the event only for the specific callback
|
|
724
724
|
* @example
|
|
725
725
|
* // release the registered region on the 'pointerdown' event
|
|
@@ -760,10 +760,10 @@ export function releasePointerEvent(eventType, region, callback) {
|
|
|
760
760
|
/**
|
|
761
761
|
* allows the removal of all registered event listeners from the object target.
|
|
762
762
|
* @name releaseAllPointerEvents
|
|
763
|
-
* @memberof
|
|
763
|
+
* @memberof input
|
|
764
764
|
* @public
|
|
765
765
|
* @function
|
|
766
|
-
* @param {
|
|
766
|
+
* @param {Rect|Polygon|Line|Ellipse} region the registered region to release event from
|
|
767
767
|
* @example
|
|
768
768
|
* // release all registered event on the
|
|
769
769
|
* me.input.releaseAllPointerEvents(this);
|
|
@@ -771,7 +771,7 @@ export function releasePointerEvent(eventType, region, callback) {
|
|
|
771
771
|
export function releaseAllPointerEvents(region) {
|
|
772
772
|
if (eventHandlers.has(region)) {
|
|
773
773
|
for (var i = 0; i < pointerEventList.length; i++) {
|
|
774
|
-
|
|
774
|
+
releasePointerEvent(pointerEventList[i], region);
|
|
775
775
|
}
|
|
776
776
|
};
|
|
777
777
|
};
|
|
@@ -780,7 +780,7 @@ export function releaseAllPointerEvents(region) {
|
|
|
780
780
|
* request for the pointer to be locked on the parent DOM element.
|
|
781
781
|
* (Must be called in a click event or an event that requires user interaction)
|
|
782
782
|
* @name requestPointerLock
|
|
783
|
-
* @memberof
|
|
783
|
+
* @memberof input
|
|
784
784
|
* @public
|
|
785
785
|
* @function
|
|
786
786
|
* @param {Function} [success] callback if the request is successful
|
|
@@ -805,7 +805,7 @@ export function requestPointerLock() {
|
|
|
805
805
|
/**
|
|
806
806
|
* Initiates an exit from pointer lock state
|
|
807
807
|
* @name exitPointerLock
|
|
808
|
-
* @memberof
|
|
808
|
+
* @memberof input
|
|
809
809
|
* @public
|
|
810
810
|
* @function
|
|
811
811
|
* @returns {boolean} return true if the request was successfully submitted
|
package/src/lang/deprecated.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import device from "./../system/device.js";
|
|
2
2
|
import { requestPointerLock, exitPointerLock } from "./../input/input.js";
|
|
3
|
+
import { TextureAtlas } from "./../video/texture.js";
|
|
4
|
+
import Renderer from "./../video/renderer.js";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* placeholder for all deprecated classes and corresponding alias for backward compatibility
|
|
@@ -46,12 +48,12 @@ export function warning(deprecated, replacement, version) {
|
|
|
46
48
|
* @public
|
|
47
49
|
* @type {Function}
|
|
48
50
|
* @name turnOnPointerLock
|
|
49
|
-
* @memberof
|
|
51
|
+
* @memberof device
|
|
50
52
|
* @deprecated since 10.3.0
|
|
51
|
-
* @see
|
|
53
|
+
* @see input.requestPointerLock
|
|
52
54
|
*/
|
|
53
55
|
device.turnOnPointerLock = function () {
|
|
54
|
-
warning("
|
|
56
|
+
warning("device.turnOnPointerLock()", "input.requestPointerLock()", "10.3.0");
|
|
55
57
|
return requestPointerLock();
|
|
56
58
|
};
|
|
57
59
|
|
|
@@ -59,11 +61,28 @@ device.turnOnPointerLock = function () {
|
|
|
59
61
|
* @public
|
|
60
62
|
* @type {Function}
|
|
61
63
|
* @name turnOffPointerLock
|
|
62
|
-
* @memberof
|
|
64
|
+
* @memberof device
|
|
63
65
|
* @deprecated since 10.3.0
|
|
64
|
-
* @see
|
|
66
|
+
* @see input.exitPointerLock
|
|
65
67
|
*/
|
|
66
68
|
device.turnOffPointerLock = function () {
|
|
67
|
-
warning("
|
|
69
|
+
warning("device.turnOffPointerLock()", "input.exitPointerLock()", "10.3.0");
|
|
68
70
|
return exitPointerLock();
|
|
69
71
|
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
* @name Texture
|
|
76
|
+
* @memberof Renderer
|
|
77
|
+
* @deprecated since 10.4.0
|
|
78
|
+
* @see TextureAtlas
|
|
79
|
+
*/
|
|
80
|
+
Object.defineProperty(Renderer.prototype, "Texture", {
|
|
81
|
+
/**
|
|
82
|
+
* @ignore
|
|
83
|
+
*/
|
|
84
|
+
get : function () {
|
|
85
|
+
warning("me.video.renderer.Texture", "me.TextureAtlas", "10.4.0");
|
|
86
|
+
return TextureAtlas;
|
|
87
|
+
}
|
|
88
|
+
});
|
package/src/level/level.js
CHANGED
|
@@ -49,10 +49,10 @@ function safeLoadLevel(levelId, options, restart) {
|
|
|
49
49
|
/**
|
|
50
50
|
* Load a TMX level
|
|
51
51
|
* @name loadTMXLevel
|
|
52
|
-
* @memberof
|
|
52
|
+
* @memberof level
|
|
53
53
|
* @private
|
|
54
54
|
* @param {string} levelId level id
|
|
55
|
-
* @param {
|
|
55
|
+
* @param {Container} container target container
|
|
56
56
|
* @param {boolean} [flatten=true] if true, flatten all objects into the given container
|
|
57
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.
|
|
58
58
|
* @ignore
|
|
@@ -76,7 +76,6 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
|
|
|
76
76
|
/**
|
|
77
77
|
* a level manager. once ressources loaded, the level manager contains all references of defined levels.
|
|
78
78
|
* @namespace level
|
|
79
|
-
* @memberof me
|
|
80
79
|
*/
|
|
81
80
|
|
|
82
81
|
var level = {
|
|
@@ -84,7 +83,7 @@ var level = {
|
|
|
84
83
|
/**
|
|
85
84
|
* add a level into the game manager (usually called by the preloader)
|
|
86
85
|
* @name add
|
|
87
|
-
* @memberof
|
|
86
|
+
* @memberof level
|
|
88
87
|
* @public
|
|
89
88
|
* @function
|
|
90
89
|
* @param {string} format level format (only "tmx" supported)
|
|
@@ -123,14 +122,14 @@ var level = {
|
|
|
123
122
|
* load a level into the game manager<br>
|
|
124
123
|
* (will also create all level defined entities, etc..)
|
|
125
124
|
* @name load
|
|
126
|
-
* @memberof
|
|
125
|
+
* @memberof level
|
|
127
126
|
* @public
|
|
128
127
|
* @function
|
|
129
128
|
* @param {string} levelId level id
|
|
130
129
|
* @param {object} [options] additional optional parameters
|
|
131
|
-
* @param {
|
|
132
|
-
* @param {Function} [options.onLoaded=
|
|
133
|
-
* @param {boolean} [options.flatten=
|
|
130
|
+
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
131
|
+
* @param {Function} [options.onLoaded=ame.onLevelLoaded] callback for when the level is fully loaded
|
|
132
|
+
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
134
133
|
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
135
134
|
* @returns {boolean} true if the level was successfully loaded
|
|
136
135
|
* @example
|
|
@@ -197,7 +196,7 @@ var level = {
|
|
|
197
196
|
/**
|
|
198
197
|
* return the current level id<br>
|
|
199
198
|
* @name getCurrentLevelId
|
|
200
|
-
* @memberof
|
|
199
|
+
* @memberof level
|
|
201
200
|
* @public
|
|
202
201
|
* @function
|
|
203
202
|
* @returns {string}
|
|
@@ -211,10 +210,10 @@ var level = {
|
|
|
211
210
|
* for a reference to the live instantiated level,
|
|
212
211
|
* rather use the container in which it was loaded (e.g. me.game.world)
|
|
213
212
|
* @name getCurrentLevel
|
|
214
|
-
* @memberof
|
|
213
|
+
* @memberof level
|
|
215
214
|
* @public
|
|
216
215
|
* @function
|
|
217
|
-
* @returns {
|
|
216
|
+
* @returns {TMXTileMap}
|
|
218
217
|
*/
|
|
219
218
|
getCurrentLevel() {
|
|
220
219
|
return levels[this.getCurrentLevelId()];
|
|
@@ -223,13 +222,13 @@ var level = {
|
|
|
223
222
|
/**
|
|
224
223
|
* reload the current level
|
|
225
224
|
* @name reload
|
|
226
|
-
* @memberof
|
|
225
|
+
* @memberof level
|
|
227
226
|
* @public
|
|
228
227
|
* @function
|
|
229
228
|
* @param {object} [options] additional optional parameters
|
|
230
|
-
* @param {
|
|
231
|
-
* @param {Function} [options.onLoaded=
|
|
232
|
-
* @param {boolean} [options.flatten=
|
|
229
|
+
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
230
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
231
|
+
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
233
232
|
* @returns {object} the current level
|
|
234
233
|
*/
|
|
235
234
|
reload(options) {
|
|
@@ -241,13 +240,13 @@ var level = {
|
|
|
241
240
|
/**
|
|
242
241
|
* load the next level
|
|
243
242
|
* @name next
|
|
244
|
-
* @memberof
|
|
243
|
+
* @memberof level
|
|
245
244
|
* @public
|
|
246
245
|
* @function
|
|
247
246
|
* @param {object} [options] additional optional parameters
|
|
248
|
-
* @param {
|
|
249
|
-
* @param {Function} [options.onLoaded=
|
|
250
|
-
* @param {boolean} [options.flatten=
|
|
247
|
+
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
248
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
249
|
+
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
251
250
|
* @returns {boolean} true if the next level was successfully loaded
|
|
252
251
|
*/
|
|
253
252
|
next(options) {
|
|
@@ -263,13 +262,13 @@ var level = {
|
|
|
263
262
|
/**
|
|
264
263
|
* load the previous level<br>
|
|
265
264
|
* @name previous
|
|
266
|
-
* @memberof
|
|
265
|
+
* @memberof level
|
|
267
266
|
* @public
|
|
268
267
|
* @function
|
|
269
268
|
* @param {object} [options] additional optional parameters
|
|
270
|
-
* @param {
|
|
271
|
-
* @param {Function} [options.onLoaded=
|
|
272
|
-
* @param {boolean} [options.flatten=
|
|
269
|
+
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
270
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
271
|
+
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
273
272
|
* @returns {boolean} true if the previous level was successfully loaded
|
|
274
273
|
*/
|
|
275
274
|
previous(options) {
|
|
@@ -285,7 +284,7 @@ var level = {
|
|
|
285
284
|
/**
|
|
286
285
|
* return the amount of level preloaded
|
|
287
286
|
* @name levelCount
|
|
288
|
-
* @memberof
|
|
287
|
+
* @memberof level
|
|
289
288
|
* @public
|
|
290
289
|
* @function
|
|
291
290
|
* @returns {number} the amount of level preloaded
|
|
@@ -7,7 +7,6 @@ import { clamp } from "./../../math/math.js";
|
|
|
7
7
|
* @classdesc
|
|
8
8
|
* object group definition as defined in Tiled.
|
|
9
9
|
* (group definition is translated into the virtual `me.game.world` using `me.Container`)
|
|
10
|
-
* @class TMXGroup
|
|
11
10
|
* @ignore
|
|
12
11
|
*/
|
|
13
12
|
export default class TMXGroup {
|
|
@@ -19,7 +18,7 @@ export default class TMXGroup {
|
|
|
19
18
|
* @public
|
|
20
19
|
* @type {string}
|
|
21
20
|
* @name name
|
|
22
|
-
* @memberof
|
|
21
|
+
* @memberof TMXGroup
|
|
23
22
|
*/
|
|
24
23
|
this.name = data.name;
|
|
25
24
|
|
|
@@ -28,7 +27,7 @@ export default class TMXGroup {
|
|
|
28
27
|
* @public
|
|
29
28
|
* @type {number}
|
|
30
29
|
* @name width
|
|
31
|
-
* @memberof
|
|
30
|
+
* @memberof TMXGroup
|
|
32
31
|
*/
|
|
33
32
|
this.width = data.width || 0;
|
|
34
33
|
|
|
@@ -37,7 +36,7 @@ export default class TMXGroup {
|
|
|
37
36
|
* @public
|
|
38
37
|
* @type {number}
|
|
39
38
|
* @name height
|
|
40
|
-
* @memberof
|
|
39
|
+
* @memberof TMXGroup
|
|
41
40
|
*/
|
|
42
41
|
this.height = data.height || 0;
|
|
43
42
|
|
|
@@ -46,7 +45,7 @@ export default class TMXGroup {
|
|
|
46
45
|
* @public
|
|
47
46
|
* @type {string}
|
|
48
47
|
* @name tintcolor
|
|
49
|
-
* @memberof
|
|
48
|
+
* @memberof TMXGroup
|
|
50
49
|
*/
|
|
51
50
|
this.tintcolor = data.tintcolor;
|
|
52
51
|
|
|
@@ -55,17 +54,17 @@ export default class TMXGroup {
|
|
|
55
54
|
* @public
|
|
56
55
|
* @type {number}
|
|
57
56
|
* @name z
|
|
58
|
-
* @memberof
|
|
57
|
+
* @memberof TMXGroup
|
|
59
58
|
*/
|
|
60
59
|
this.z = z;
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* group objects list definition
|
|
64
|
-
* @see
|
|
63
|
+
* @see TMXObject
|
|
65
64
|
* @public
|
|
66
65
|
* @type {object[]}
|
|
67
66
|
* @name name
|
|
68
|
-
* @memberof
|
|
67
|
+
* @memberof TMXGroup
|
|
69
68
|
*/
|
|
70
69
|
this.objects = [];
|
|
71
70
|
|
|
@@ -63,22 +63,20 @@ function preRenderLayer(layer, renderer) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
+
* @classdesc
|
|
66
67
|
* a TMX Tile Layer Object
|
|
67
68
|
* Tiled QT 0.7.x format
|
|
68
|
-
* @
|
|
69
|
-
* @augments me.Renderable
|
|
70
|
-
* @memberof me
|
|
71
|
-
* @param {object} map layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
72
|
-
* @param {object} data layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
73
|
-
* @param {number} tilewidth width of each tile in pixels
|
|
74
|
-
* @param {number} tileheight height of each tile in pixels
|
|
75
|
-
* @param {string} orientation "isometric" or "orthogonal"
|
|
76
|
-
* @param {me.TMXTilesetGroup} tilesets tileset as defined in Tiled
|
|
77
|
-
* @param {number} z z-index position
|
|
69
|
+
* @augments Renderable
|
|
78
70
|
*/
|
|
79
71
|
class TMXLayer extends Renderable {
|
|
80
72
|
/**
|
|
81
|
-
* @
|
|
73
|
+
* @param {object} map layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
74
|
+
* @param {object} data layer data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#layer})
|
|
75
|
+
* @param {number} tilewidth width of each tile in pixels
|
|
76
|
+
* @param {number} tileheight height of each tile in pixels
|
|
77
|
+
* @param {string} orientation "isometric" or "orthogonal"
|
|
78
|
+
* @param {TMXTilesetGroup} tilesets tileset as defined in Tiled
|
|
79
|
+
* @param {number} z z-index position
|
|
82
80
|
*/
|
|
83
81
|
constructor(map, data, tilewidth, tileheight, orientation, tilesets, z) {
|
|
84
82
|
// super constructor
|
|
@@ -94,8 +92,8 @@ class TMXLayer extends Renderable {
|
|
|
94
92
|
/**
|
|
95
93
|
* The Layer corresponding Tilesets
|
|
96
94
|
* @public
|
|
97
|
-
* @type {
|
|
98
|
-
* @name
|
|
95
|
+
* @type {TMXTilesetGroup}
|
|
96
|
+
* @name TMXLayer#tilesets
|
|
99
97
|
*/
|
|
100
98
|
this.tilesets = tilesets;
|
|
101
99
|
|
|
@@ -117,8 +115,8 @@ class TMXLayer extends Renderable {
|
|
|
117
115
|
/**
|
|
118
116
|
* All animated tilesets in this layer
|
|
119
117
|
* @ignore
|
|
120
|
-
* @type {
|
|
121
|
-
* @name
|
|
118
|
+
* @type {TMXTileset[]}
|
|
119
|
+
* @name TMXLayer#animatedTilesets
|
|
122
120
|
*/
|
|
123
121
|
this.animatedTilesets = [];
|
|
124
122
|
|
|
@@ -126,7 +124,7 @@ class TMXLayer extends Renderable {
|
|
|
126
124
|
* Layer contains tileset animations
|
|
127
125
|
* @public
|
|
128
126
|
* @type {boolean}
|
|
129
|
-
* @name
|
|
127
|
+
* @name TMXLayer#isAnimated
|
|
130
128
|
*/
|
|
131
129
|
this.isAnimated = false;
|
|
132
130
|
|
|
@@ -136,7 +134,7 @@ class TMXLayer extends Renderable {
|
|
|
136
134
|
* @public
|
|
137
135
|
* @type {string}
|
|
138
136
|
* @default "right-down"
|
|
139
|
-
* @name
|
|
137
|
+
* @name TMXLayer#renderorder
|
|
140
138
|
*/
|
|
141
139
|
this.renderorder = data.renderorder || "right-down";
|
|
142
140
|
|
|
@@ -242,10 +240,10 @@ class TMXLayer extends Renderable {
|
|
|
242
240
|
/**
|
|
243
241
|
* Set the TMX renderer for this layer object
|
|
244
242
|
* @name setRenderer
|
|
245
|
-
* @memberof
|
|
243
|
+
* @memberof TMXLayer
|
|
246
244
|
* @public
|
|
247
245
|
* @function
|
|
248
|
-
* @param {
|
|
246
|
+
* @param {TMXRenderer} renderer
|
|
249
247
|
* @example
|
|
250
248
|
* // use the parent map default renderer
|
|
251
249
|
* var layer = new me.TMXLayer(...);
|
|
@@ -258,10 +256,10 @@ class TMXLayer extends Renderable {
|
|
|
258
256
|
/**
|
|
259
257
|
* Return the layer current renderer object
|
|
260
258
|
* @name getRenderer
|
|
261
|
-
* @memberof
|
|
259
|
+
* @memberof TMXLayer
|
|
262
260
|
* @public
|
|
263
261
|
* @function
|
|
264
|
-
* @returns {
|
|
262
|
+
* @returns {TMXRenderer} renderer
|
|
265
263
|
*/
|
|
266
264
|
getRenderer() {
|
|
267
265
|
return this.renderer;
|
|
@@ -271,7 +269,7 @@ class TMXLayer extends Renderable {
|
|
|
271
269
|
/**
|
|
272
270
|
* Return the TileId of the Tile at the specified position
|
|
273
271
|
* @name getTileId
|
|
274
|
-
* @memberof
|
|
272
|
+
* @memberof TMXLayer
|
|
275
273
|
* @public
|
|
276
274
|
* @function
|
|
277
275
|
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
@@ -286,12 +284,12 @@ class TMXLayer extends Renderable {
|
|
|
286
284
|
/**
|
|
287
285
|
* Return the Tile object at the specified position
|
|
288
286
|
* @name getTile
|
|
289
|
-
* @memberof
|
|
287
|
+
* @memberof TMXLayer
|
|
290
288
|
* @public
|
|
291
289
|
* @function
|
|
292
290
|
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
293
291
|
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
294
|
-
* @returns {
|
|
292
|
+
* @returns {Tile} corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds
|
|
295
293
|
* @example
|
|
296
294
|
* // get the TMX Map Layer called "Front layer"
|
|
297
295
|
* var layer = me.game.world.getChildByName("Front Layer")[0];
|
|
@@ -312,13 +310,13 @@ class TMXLayer extends Renderable {
|
|
|
312
310
|
/**
|
|
313
311
|
* assign the given Tile object to the specified position
|
|
314
312
|
* @name getTile
|
|
315
|
-
* @memberof
|
|
313
|
+
* @memberof TMXLayer
|
|
316
314
|
* @public
|
|
317
315
|
* @function
|
|
318
|
-
* @param {
|
|
316
|
+
* @param {Tile} tile the tile object to be assigned
|
|
319
317
|
* @param {number} x x coordinate (in world/pixels coordinates)
|
|
320
318
|
* @param {number} y y coordinate (in world/pixels coordinates)
|
|
321
|
-
* @returns {
|
|
319
|
+
* @returns {Tile} the tile object
|
|
322
320
|
*/
|
|
323
321
|
setTile(tile, x, y) {
|
|
324
322
|
this.layerData[x][y] = tile;
|
|
@@ -328,13 +326,13 @@ class TMXLayer extends Renderable {
|
|
|
328
326
|
/**
|
|
329
327
|
* return a new the Tile object corresponding to the given tile id
|
|
330
328
|
* @name setTile
|
|
331
|
-
* @memberof
|
|
329
|
+
* @memberof TMXLayer
|
|
332
330
|
* @public
|
|
333
331
|
* @function
|
|
334
332
|
* @param {number} tileId tileId
|
|
335
333
|
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
336
334
|
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
337
|
-
* @returns {
|
|
335
|
+
* @returns {Tile} the tile object
|
|
338
336
|
*/
|
|
339
337
|
getTileById(tileId, x, y) {
|
|
340
338
|
if (!this.tileset.contains(tileId)) {
|
|
@@ -347,13 +345,13 @@ class TMXLayer extends Renderable {
|
|
|
347
345
|
/**
|
|
348
346
|
* Return the Tile object at the specified tile coordinates
|
|
349
347
|
* @name cellAt
|
|
350
|
-
* @memberof
|
|
348
|
+
* @memberof TMXLayer
|
|
351
349
|
* @public
|
|
352
350
|
* @function
|
|
353
351
|
* @param {number} x x position of the tile (in Tile unit)
|
|
354
352
|
* @param {number} y x position of the tile (in Tile unit)
|
|
355
353
|
* @param {number} [boundsCheck=true] check first if within the layer bounds
|
|
356
|
-
* @returns {
|
|
354
|
+
* @returns {Tile} corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds
|
|
357
355
|
* @example
|
|
358
356
|
* // return the first tile at offset 0, 0
|
|
359
357
|
* var tile = layer.cellAt(0, 0);
|
|
@@ -374,7 +372,7 @@ class TMXLayer extends Renderable {
|
|
|
374
372
|
/**
|
|
375
373
|
* clear the tile at the specified position
|
|
376
374
|
* @name clearTile
|
|
377
|
-
* @memberof
|
|
375
|
+
* @memberof TMXLayer
|
|
378
376
|
* @public
|
|
379
377
|
* @function
|
|
380
378
|
* @param {number} x X coordinate (in map coordinates: row/column)
|