melonjs 10.9.0 → 10.12.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/LICENSE.md +1 -1
- package/README.md +32 -25
- package/dist/melonjs.js +1635 -2383
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +929 -1504
- package/dist/melonjs.module.js +1581 -2344
- package/package.json +18 -18
- package/src/audio/audio.js +0 -1
- package/src/camera/camera2d.js +1 -16
- package/src/entity/entity.js +6 -11
- package/src/game.js +2 -2
- package/src/geometries/ellipse.js +19 -28
- package/src/geometries/line.js +5 -8
- package/src/geometries/path2d.js +14 -24
- package/src/geometries/poly.js +29 -47
- package/src/geometries/rectangle.js +25 -37
- package/src/geometries/roundrect.js +8 -12
- package/src/index.js +7 -2
- package/src/input/gamepad.js +3 -14
- package/src/input/keyboard.js +1 -9
- package/src/input/pointer.js +0 -1
- package/src/input/pointerevent.js +14 -23
- package/src/lang/deprecated.js +9 -6
- package/src/level/level.js +0 -9
- package/src/level/tiled/TMXGroup.js +0 -4
- package/src/level/tiled/TMXLayer.js +0 -8
- package/src/level/tiled/TMXObject.js +0 -3
- package/src/level/tiled/TMXTile.js +4 -5
- package/src/level/tiled/TMXTileMap.js +1 -7
- package/src/level/tiled/TMXTileset.js +0 -5
- package/src/level/tiled/TMXTilesetGroup.js +1 -4
- package/src/level/tiled/TMXUtils.js +1 -4
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -7
- package/src/loader/loader.js +0 -11
- package/src/loader/loadingscreen.js +16 -5
- package/src/math/color.js +10 -30
- package/src/math/math.js +0 -10
- package/src/math/matrix2.js +12 -27
- package/src/math/matrix3.js +1 -22
- package/src/math/observable_vector2.js +0 -29
- package/src/math/observable_vector3.js +0 -29
- package/src/math/vector2.js +3 -40
- package/src/math/vector3.js +4 -41
- package/src/particles/emitter.js +11 -12
- package/src/physics/body.js +4 -5
- package/src/physics/bounds.js +5 -19
- package/src/physics/collision.js +1 -13
- package/src/physics/detector.js +6 -56
- package/src/physics/quadtree.js +0 -7
- package/src/physics/response.js +48 -0
- package/src/physics/sat.js +4 -4
- package/src/physics/world.js +0 -4
- package/src/plugin/plugin.js +0 -2
- package/src/polyfill/roundrect.js +4 -2
- package/src/renderable/GUI.js +11 -14
- package/src/renderable/collectable.js +1 -0
- package/src/renderable/colorlayer.js +9 -7
- package/src/renderable/container.js +38 -64
- package/src/renderable/dragndrop.js +1 -10
- package/src/renderable/imagelayer.js +8 -12
- package/src/renderable/light2d.js +118 -0
- package/src/renderable/renderable.js +27 -48
- package/src/renderable/sprite.js +17 -29
- package/src/renderable/trigger.js +10 -3
- package/src/state/stage.js +72 -6
- package/src/state/state.js +22 -23
- package/src/system/device.js +14 -53
- package/src/system/event.js +11 -0
- package/src/system/pooling.js +20 -9
- package/src/system/save.js +9 -11
- package/src/system/timer.js +239 -218
- package/src/text/bitmaptextdata.js +1 -4
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +25 -24
- package/src/text/textmetrics.js +0 -2
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +2 -2
- package/src/tweens/tween.js +1 -13
- package/src/utils/agent.js +1 -3
- package/src/utils/array.js +0 -3
- package/src/utils/file.js +0 -2
- package/src/utils/function.js +0 -2
- package/src/utils/string.js +0 -6
- package/src/utils/utils.js +0 -3
- package/src/video/canvas/canvas_renderer.js +73 -90
- package/src/video/renderer.js +34 -49
- package/src/video/{texture.js → texture/atlas.js} +10 -8
- package/src/video/{texture_cache.js → texture/cache.js} +4 -5
- package/src/video/texture/canvas_texture.js +99 -0
- package/src/video/video.js +3 -3
- package/src/video/webgl/glshader.js +0 -5
- package/src/video/webgl/utils/uniforms.js +3 -6
- package/src/video/webgl/webgl_compositor.js +0 -14
- package/src/video/webgl/webgl_renderer.js +73 -97
package/src/input/pointer.js
CHANGED
|
@@ -311,7 +311,6 @@ class Pointer extends Bounds {
|
|
|
311
311
|
* initialize the Pointer object using the given Event Object
|
|
312
312
|
* @name Pointer#set
|
|
313
313
|
* @private
|
|
314
|
-
* @function
|
|
315
314
|
* @param {Event} event the original Event object
|
|
316
315
|
* @param {number} [pageX=0] the horizontal coordinate at which the event occurred, relative to the left edge of the entire document
|
|
317
316
|
* @param {number} [pageY=0] the vertical coordinate at which the event occurred, relative to the left edge of the entire document
|
|
@@ -35,17 +35,17 @@ var lastTimeStamp = 0;
|
|
|
35
35
|
var activeEventList = [];
|
|
36
36
|
|
|
37
37
|
// internal constants
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const WHEEL = ["wheel"];
|
|
39
|
+
const POINTER_MOVE = ["pointermove", "mousemove", "touchmove"];
|
|
40
|
+
const POINTER_DOWN = ["pointerdown", "mousedown", "touchstart"];
|
|
41
|
+
const POINTER_UP = ["pointerup", "mouseup", "touchend"];
|
|
42
|
+
const POINTER_CANCEL = ["pointercancel", "mousecancel", "touchcancel"];
|
|
43
|
+
const POINTER_ENTER = ["pointerenter", "mouseenter", "touchenter"];
|
|
44
|
+
const POINTER_OVER = ["pointerover", "mouseover", "touchover"];
|
|
45
|
+
const POINTER_LEAVE = ["pointerleave", "mouseleave", "touchleave"];
|
|
46
46
|
|
|
47
47
|
// list of standard pointer event type
|
|
48
|
-
|
|
48
|
+
const pointerEventList = [
|
|
49
49
|
WHEEL[0],
|
|
50
50
|
POINTER_MOVE[0],
|
|
51
51
|
POINTER_DOWN[0],
|
|
@@ -57,7 +57,7 @@ var pointerEventList = [
|
|
|
57
57
|
];
|
|
58
58
|
|
|
59
59
|
// legacy mouse event type
|
|
60
|
-
|
|
60
|
+
const mouseEventList = [
|
|
61
61
|
WHEEL[0],
|
|
62
62
|
POINTER_MOVE[1],
|
|
63
63
|
POINTER_DOWN[1],
|
|
@@ -69,7 +69,7 @@ var mouseEventList = [
|
|
|
69
69
|
];
|
|
70
70
|
|
|
71
71
|
// iOS style touch event type
|
|
72
|
-
|
|
72
|
+
const touchEventList = [
|
|
73
73
|
POINTER_MOVE[2],
|
|
74
74
|
POINTER_DOWN[2],
|
|
75
75
|
POINTER_UP[2],
|
|
@@ -79,7 +79,7 @@ var touchEventList = [
|
|
|
79
79
|
POINTER_LEAVE[2]
|
|
80
80
|
];
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
const pointerEventMap = {
|
|
83
83
|
wheel : WHEEL,
|
|
84
84
|
pointermove: POINTER_MOVE,
|
|
85
85
|
pointerdown: POINTER_DOWN,
|
|
@@ -264,8 +264,8 @@ function dispatchEvent(normalizedEvents) {
|
|
|
264
264
|
// and put it back into our cache
|
|
265
265
|
T_POINTERS.push(pointer);
|
|
266
266
|
|
|
267
|
-
// Do not fire older events
|
|
268
|
-
if (typeof(pointer.event.timeStamp) !== "undefined") {
|
|
267
|
+
// Do not fire older touch events (not required for PointerEvent type)
|
|
268
|
+
if (pointer.isNormalized === true && typeof(pointer.event.timeStamp) !== "undefined") {
|
|
269
269
|
if (pointer.event.timeStamp < lastTimeStamp) {
|
|
270
270
|
continue;
|
|
271
271
|
}
|
|
@@ -543,7 +543,6 @@ export var throttlingInterval;
|
|
|
543
543
|
* @name globalToLocal
|
|
544
544
|
* @memberof input
|
|
545
545
|
* @public
|
|
546
|
-
* @function
|
|
547
546
|
* @param {number} x the global x coordinate to be translated.
|
|
548
547
|
* @param {number} y the global y coordinate to be translated.
|
|
549
548
|
* @param {Vector2d} [v] an optional vector object where to set the translated coordinates
|
|
@@ -576,7 +575,6 @@ export function globalToLocal(x, y, v) {
|
|
|
576
575
|
* @memberof input
|
|
577
576
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action
|
|
578
577
|
* @public
|
|
579
|
-
* @function
|
|
580
578
|
* @param {HTMLCanvasElement} element
|
|
581
579
|
* @param {string} [value="none"]
|
|
582
580
|
*/
|
|
@@ -592,7 +590,6 @@ export function setTouchAction(element, value) {
|
|
|
592
590
|
* @name bindPointer
|
|
593
591
|
* @memberof input
|
|
594
592
|
* @public
|
|
595
|
-
* @function
|
|
596
593
|
* @param {number} [button=input.pointer.LEFT] (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
597
594
|
* @param {input.KEY} keyCode
|
|
598
595
|
* @example
|
|
@@ -623,7 +620,6 @@ export function bindPointer() {
|
|
|
623
620
|
* @name unbindPointer
|
|
624
621
|
* @memberof input
|
|
625
622
|
* @public
|
|
626
|
-
* @function
|
|
627
623
|
* @param {number} [button=input.pointer.LEFT] (accordingly to W3C values : 0,1,2 for left, middle and right buttons)
|
|
628
624
|
* @example
|
|
629
625
|
* me.input.unbindPointer(me.input.pointer.LEFT);
|
|
@@ -645,7 +641,6 @@ export function unbindPointer(button) {
|
|
|
645
641
|
* @name registerPointerEvent
|
|
646
642
|
* @memberof input
|
|
647
643
|
* @public
|
|
648
|
-
* @function
|
|
649
644
|
* @param {string} eventType The event type for which the object is registering <br>
|
|
650
645
|
* melonJS currently supports: <br>
|
|
651
646
|
* <ul>
|
|
@@ -717,7 +712,6 @@ export function registerPointerEvent(eventType, region, callback) {
|
|
|
717
712
|
* @name releasePointerEvent
|
|
718
713
|
* @memberof input
|
|
719
714
|
* @public
|
|
720
|
-
* @function
|
|
721
715
|
* @param {string} eventType The event type for which the object was registered. See {@link input.registerPointerEvent}
|
|
722
716
|
* @param {Rect|Polygon|Line|Ellipse} region the registered region to release for this event
|
|
723
717
|
* @param {Function} [callback="all"] if specified unregister the event only for the specific callback
|
|
@@ -762,7 +756,6 @@ export function releasePointerEvent(eventType, region, callback) {
|
|
|
762
756
|
* @name releaseAllPointerEvents
|
|
763
757
|
* @memberof input
|
|
764
758
|
* @public
|
|
765
|
-
* @function
|
|
766
759
|
* @param {Rect|Polygon|Line|Ellipse} region the registered region to release event from
|
|
767
760
|
* @example
|
|
768
761
|
* // release all registered event on the
|
|
@@ -782,7 +775,6 @@ export function releaseAllPointerEvents(region) {
|
|
|
782
775
|
* @name requestPointerLock
|
|
783
776
|
* @memberof input
|
|
784
777
|
* @public
|
|
785
|
-
* @function
|
|
786
778
|
* @returns {boolean} return true if the request was successfully submitted
|
|
787
779
|
* @example
|
|
788
780
|
* // register on the pointer lock change event
|
|
@@ -806,7 +798,6 @@ export function requestPointerLock() {
|
|
|
806
798
|
* @name exitPointerLock
|
|
807
799
|
* @memberof input
|
|
808
800
|
* @public
|
|
809
|
-
* @function
|
|
810
801
|
* @returns {boolean} return true if the request was successfully submitted
|
|
811
802
|
*/
|
|
812
803
|
export function exitPointerLock() {
|
package/src/lang/deprecated.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import device from "./../system/device.js";
|
|
2
2
|
import { requestPointerLock, exitPointerLock } from "./../input/input.js";
|
|
3
|
-
import { TextureAtlas } from "./../video/texture.js";
|
|
3
|
+
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
4
4
|
import Renderer from "./../video/renderer.js";
|
|
5
5
|
import { Draggable, DropTarget } from "./../renderable/dragndrop.js";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/*
|
|
8
8
|
* placeholder for all deprecated classes and corresponding alias for backward compatibility
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -47,9 +47,9 @@ export function warning(deprecated, replacement, version) {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* @public
|
|
50
|
-
* @type {Function}
|
|
51
50
|
* @name turnOnPointerLock
|
|
52
|
-
* @
|
|
51
|
+
* @returns {boolean} return true if the request was successfully submitted
|
|
52
|
+
* @memberof device#
|
|
53
53
|
* @deprecated since 10.3.0
|
|
54
54
|
* @see input.requestPointerLock
|
|
55
55
|
*/
|
|
@@ -60,9 +60,9 @@ device.turnOnPointerLock = function () {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @public
|
|
63
|
-
* @type {Function}
|
|
64
63
|
* @name turnOffPointerLock
|
|
65
|
-
* @
|
|
64
|
+
* @returns {boolean} return true if the request was successfully submitted
|
|
65
|
+
* @memberof device#
|
|
66
66
|
* @deprecated since 10.3.0
|
|
67
67
|
* @see input.exitPointerLock
|
|
68
68
|
*/
|
|
@@ -72,8 +72,11 @@ device.turnOffPointerLock = function () {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
+
* Alias of {@link TextureAtlas}
|
|
76
|
+
*
|
|
75
77
|
* @public
|
|
76
78
|
* @name Texture
|
|
79
|
+
* @class
|
|
77
80
|
* @memberof Renderer#
|
|
78
81
|
* @deprecated since 10.4.0
|
|
79
82
|
* @see TextureAtlas
|
package/src/level/level.js
CHANGED
|
@@ -56,7 +56,6 @@ function safeLoadLevel(levelId, options, restart) {
|
|
|
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
|
|
59
|
-
* @function
|
|
60
59
|
*/
|
|
61
60
|
function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
|
|
62
61
|
var level = levels[levelId];
|
|
@@ -85,7 +84,6 @@ var level = {
|
|
|
85
84
|
* @name add
|
|
86
85
|
* @memberof level
|
|
87
86
|
* @public
|
|
88
|
-
* @function
|
|
89
87
|
* @param {string} format level format (only "tmx" supported)
|
|
90
88
|
* @param {string} levelId the level id (or name)
|
|
91
89
|
* @param {Function} [callback] a function to be called once the level is loaded
|
|
@@ -124,7 +122,6 @@ var level = {
|
|
|
124
122
|
* @name load
|
|
125
123
|
* @memberof level
|
|
126
124
|
* @public
|
|
127
|
-
* @function
|
|
128
125
|
* @param {string} levelId level id
|
|
129
126
|
* @param {object} [options] additional optional parameters
|
|
130
127
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
@@ -198,7 +195,6 @@ var level = {
|
|
|
198
195
|
* @name getCurrentLevelId
|
|
199
196
|
* @memberof level
|
|
200
197
|
* @public
|
|
201
|
-
* @function
|
|
202
198
|
* @returns {string}
|
|
203
199
|
*/
|
|
204
200
|
getCurrentLevelId() {
|
|
@@ -212,7 +208,6 @@ var level = {
|
|
|
212
208
|
* @name getCurrentLevel
|
|
213
209
|
* @memberof level
|
|
214
210
|
* @public
|
|
215
|
-
* @function
|
|
216
211
|
* @returns {TMXTileMap}
|
|
217
212
|
*/
|
|
218
213
|
getCurrentLevel() {
|
|
@@ -224,7 +219,6 @@ var level = {
|
|
|
224
219
|
* @name reload
|
|
225
220
|
* @memberof level
|
|
226
221
|
* @public
|
|
227
|
-
* @function
|
|
228
222
|
* @param {object} [options] additional optional parameters
|
|
229
223
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
230
224
|
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
@@ -242,7 +236,6 @@ var level = {
|
|
|
242
236
|
* @name next
|
|
243
237
|
* @memberof level
|
|
244
238
|
* @public
|
|
245
|
-
* @function
|
|
246
239
|
* @param {object} [options] additional optional parameters
|
|
247
240
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
248
241
|
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
@@ -264,7 +257,6 @@ var level = {
|
|
|
264
257
|
* @name previous
|
|
265
258
|
* @memberof level
|
|
266
259
|
* @public
|
|
267
|
-
* @function
|
|
268
260
|
* @param {object} [options] additional optional parameters
|
|
269
261
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
270
262
|
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
@@ -286,7 +278,6 @@ var level = {
|
|
|
286
278
|
* @name levelCount
|
|
287
279
|
* @memberof level
|
|
288
280
|
* @public
|
|
289
|
-
* @function
|
|
290
281
|
* @returns {number} the amount of level preloaded
|
|
291
282
|
*/
|
|
292
283
|
levelCount() {
|
|
@@ -98,9 +98,7 @@ export default class TMXGroup {
|
|
|
98
98
|
/**
|
|
99
99
|
* reset function
|
|
100
100
|
* @ignore
|
|
101
|
-
* @function
|
|
102
101
|
*/
|
|
103
|
-
|
|
104
102
|
destroy() {
|
|
105
103
|
// clear all allocated objects
|
|
106
104
|
this.objects = null;
|
|
@@ -109,7 +107,6 @@ export default class TMXGroup {
|
|
|
109
107
|
/**
|
|
110
108
|
* return the object count
|
|
111
109
|
* @ignore
|
|
112
|
-
* @function
|
|
113
110
|
*/
|
|
114
111
|
getObjectCount() {
|
|
115
112
|
return this.objects.length;
|
|
@@ -118,7 +115,6 @@ export default class TMXGroup {
|
|
|
118
115
|
/**
|
|
119
116
|
* returns the object at the specified index
|
|
120
117
|
* @ignore
|
|
121
|
-
* @function
|
|
122
118
|
*/
|
|
123
119
|
getObjectByIndex(idx) {
|
|
124
120
|
return this.objects[idx];
|
|
@@ -242,7 +242,6 @@ class TMXLayer extends Renderable {
|
|
|
242
242
|
* @name setRenderer
|
|
243
243
|
* @memberof TMXLayer
|
|
244
244
|
* @public
|
|
245
|
-
* @function
|
|
246
245
|
* @param {TMXRenderer} renderer
|
|
247
246
|
* @example
|
|
248
247
|
* // use the parent map default renderer
|
|
@@ -258,7 +257,6 @@ class TMXLayer extends Renderable {
|
|
|
258
257
|
* @name getRenderer
|
|
259
258
|
* @memberof TMXLayer
|
|
260
259
|
* @public
|
|
261
|
-
* @function
|
|
262
260
|
* @returns {TMXRenderer} renderer
|
|
263
261
|
*/
|
|
264
262
|
getRenderer() {
|
|
@@ -271,7 +269,6 @@ class TMXLayer extends Renderable {
|
|
|
271
269
|
* @name getTileId
|
|
272
270
|
* @memberof TMXLayer
|
|
273
271
|
* @public
|
|
274
|
-
* @function
|
|
275
272
|
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
276
273
|
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
277
274
|
* @returns {number} TileId or null if there is no Tile at the given position
|
|
@@ -286,7 +283,6 @@ class TMXLayer extends Renderable {
|
|
|
286
283
|
* @name getTile
|
|
287
284
|
* @memberof TMXLayer
|
|
288
285
|
* @public
|
|
289
|
-
* @function
|
|
290
286
|
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
291
287
|
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
292
288
|
* @returns {Tile} corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds
|
|
@@ -312,7 +308,6 @@ class TMXLayer extends Renderable {
|
|
|
312
308
|
* @name getTile
|
|
313
309
|
* @memberof TMXLayer
|
|
314
310
|
* @public
|
|
315
|
-
* @function
|
|
316
311
|
* @param {Tile} tile the tile object to be assigned
|
|
317
312
|
* @param {number} x x coordinate (in world/pixels coordinates)
|
|
318
313
|
* @param {number} y y coordinate (in world/pixels coordinates)
|
|
@@ -328,7 +323,6 @@ class TMXLayer extends Renderable {
|
|
|
328
323
|
* @name setTile
|
|
329
324
|
* @memberof TMXLayer
|
|
330
325
|
* @public
|
|
331
|
-
* @function
|
|
332
326
|
* @param {number} tileId tileId
|
|
333
327
|
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
334
328
|
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
@@ -347,7 +341,6 @@ class TMXLayer extends Renderable {
|
|
|
347
341
|
* @name cellAt
|
|
348
342
|
* @memberof TMXLayer
|
|
349
343
|
* @public
|
|
350
|
-
* @function
|
|
351
344
|
* @param {number} x x position of the tile (in Tile unit)
|
|
352
345
|
* @param {number} y x position of the tile (in Tile unit)
|
|
353
346
|
* @param {number} [boundsCheck=true] check first if within the layer bounds
|
|
@@ -374,7 +367,6 @@ class TMXLayer extends Renderable {
|
|
|
374
367
|
* @name clearTile
|
|
375
368
|
* @memberof TMXLayer
|
|
376
369
|
* @public
|
|
377
|
-
* @function
|
|
378
370
|
* @param {number} x X coordinate (in map coordinates: row/column)
|
|
379
371
|
* @param {number} y Y coordinate (in map coordinates: row/column)
|
|
380
372
|
* @example
|
|
@@ -226,7 +226,6 @@ export default class TMXObject {
|
|
|
226
226
|
/**
|
|
227
227
|
* set the object image (for Tiled Object)
|
|
228
228
|
* @ignore
|
|
229
|
-
* @function
|
|
230
229
|
*/
|
|
231
230
|
setTile(tilesets) {
|
|
232
231
|
// get the corresponding tileset
|
|
@@ -247,7 +246,6 @@ export default class TMXObject {
|
|
|
247
246
|
* @name parseTMXShapes
|
|
248
247
|
* @memberof TMXObject
|
|
249
248
|
* @private
|
|
250
|
-
* @function
|
|
251
249
|
* @returns {Polygon[]|Line[]|Ellipse[]} an array of shape objects
|
|
252
250
|
*/
|
|
253
251
|
parseTMXShapes() {
|
|
@@ -318,7 +316,6 @@ export default class TMXObject {
|
|
|
318
316
|
/**
|
|
319
317
|
* getObjectPropertyByName
|
|
320
318
|
* @ignore
|
|
321
|
-
* @function
|
|
322
319
|
*/
|
|
323
320
|
getObjectPropertyByName(name) {
|
|
324
321
|
return this[name];
|
|
@@ -3,10 +3,10 @@ import Sprite from "./../../renderable/sprite.js";
|
|
|
3
3
|
import Bounds from "./../../physics/bounds.js";
|
|
4
4
|
|
|
5
5
|
// bitmask constants to check for flipped & rotated tiles
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const TMX_FLIP_H = 0x80000000,
|
|
7
|
+
TMX_FLIP_V = 0x40000000,
|
|
8
|
+
TMX_FLIP_AD = 0x20000000,
|
|
9
|
+
TMX_CLEAR_BIT_MASK = ~(0x80000000 | 0x40000000 | 0x20000000);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @classdesc
|
|
@@ -132,7 +132,6 @@ class Tile extends Bounds {
|
|
|
132
132
|
* return a renderable object for this Tile object
|
|
133
133
|
* @name Tile#getRenderable
|
|
134
134
|
* @public
|
|
135
|
-
* @function
|
|
136
135
|
* @param {object} [settings] see {@link Sprite}
|
|
137
136
|
* @returns {Renderable} a me.Sprite object
|
|
138
137
|
*/
|
|
@@ -16,7 +16,7 @@ import Renderable from "./../../renderable/renderable.js";
|
|
|
16
16
|
import Container from "./../../renderable/container.js";
|
|
17
17
|
|
|
18
18
|
// constant to identify the collision object layer
|
|
19
|
-
|
|
19
|
+
const COLLISION_GROUP = "collision";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* set a compatible renderer object
|
|
@@ -256,7 +256,6 @@ class TMXTileMap {
|
|
|
256
256
|
* @name getRenderer
|
|
257
257
|
* @memberof TMXTileMap
|
|
258
258
|
* @public
|
|
259
|
-
* @function
|
|
260
259
|
* @returns {TMXRenderer} a TMX renderer
|
|
261
260
|
*/
|
|
262
261
|
getRenderer() {
|
|
@@ -270,7 +269,6 @@ class TMXTileMap {
|
|
|
270
269
|
* return the map bounding rect
|
|
271
270
|
* @name TMXRenderer#getBounds
|
|
272
271
|
* @public
|
|
273
|
-
* @function
|
|
274
272
|
* @returns {Bounds}
|
|
275
273
|
*/
|
|
276
274
|
getBounds() {
|
|
@@ -353,7 +351,6 @@ class TMXTileMap {
|
|
|
353
351
|
* note : this will not automatically update the camera viewport
|
|
354
352
|
* @name TMXTileMap#addTo
|
|
355
353
|
* @public
|
|
356
|
-
* @function
|
|
357
354
|
* @param {Container} container target container
|
|
358
355
|
* @param {boolean} [flatten=true] if true, flatten all objects into the given container, else a `me.Container` object will be created for each corresponding groups
|
|
359
356
|
* @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.
|
|
@@ -430,7 +427,6 @@ class TMXTileMap {
|
|
|
430
427
|
* return an Array of instantiated objects, based on the map object definition
|
|
431
428
|
* @name TMXTileMap#getObjects
|
|
432
429
|
* @public
|
|
433
|
-
* @function
|
|
434
430
|
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
435
431
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
436
432
|
* @returns {Renderable[]} Array of Objects
|
|
@@ -601,7 +597,6 @@ class TMXTileMap {
|
|
|
601
597
|
* return all the existing layers
|
|
602
598
|
* @name TMXTileMap#getLayers
|
|
603
599
|
* @public
|
|
604
|
-
* @function
|
|
605
600
|
* @returns {TMXLayer[]} Array of Layers
|
|
606
601
|
*/
|
|
607
602
|
getLayers() {
|
|
@@ -614,7 +609,6 @@ class TMXTileMap {
|
|
|
614
609
|
* destroy function, clean all allocated objects
|
|
615
610
|
* @name TMXTileMap#destroy
|
|
616
611
|
* @public
|
|
617
|
-
* @function
|
|
618
612
|
*/
|
|
619
613
|
destroy() {
|
|
620
614
|
this.tilesets = undefined;
|
|
@@ -166,7 +166,6 @@ class TMXTileset {
|
|
|
166
166
|
* return the tile image from a "Collection of Image" tileset
|
|
167
167
|
* @name TMXTileset#getTileImage
|
|
168
168
|
* @public
|
|
169
|
-
* @function
|
|
170
169
|
* @param {number} gid
|
|
171
170
|
* @returns {Image} corresponding image or undefined
|
|
172
171
|
*/
|
|
@@ -178,7 +177,6 @@ class TMXTileset {
|
|
|
178
177
|
/**
|
|
179
178
|
* set the tile properties
|
|
180
179
|
* @ignore
|
|
181
|
-
* @function
|
|
182
180
|
*/
|
|
183
181
|
setTileProperty(gid, prop) {
|
|
184
182
|
// set the given tile id
|
|
@@ -189,7 +187,6 @@ class TMXTileset {
|
|
|
189
187
|
* return true if the gid belongs to the tileset
|
|
190
188
|
* @name TMXTileset#contains
|
|
191
189
|
* @public
|
|
192
|
-
* @function
|
|
193
190
|
* @param {number} gid
|
|
194
191
|
* @returns {boolean}
|
|
195
192
|
*/
|
|
@@ -201,7 +198,6 @@ class TMXTileset {
|
|
|
201
198
|
* Get the view (local) tile ID from a GID, with animations applied
|
|
202
199
|
* @name TMXTileset#getViewTileId
|
|
203
200
|
* @public
|
|
204
|
-
* @function
|
|
205
201
|
* @param {number} gid Global tile ID
|
|
206
202
|
* @returns {number} View tile ID
|
|
207
203
|
*/
|
|
@@ -220,7 +216,6 @@ class TMXTileset {
|
|
|
220
216
|
* return the properties of the specified tile
|
|
221
217
|
* @name TMXTileset#getTileProperties
|
|
222
218
|
* @public
|
|
223
|
-
* @function
|
|
224
219
|
* @param {number} tileId
|
|
225
220
|
* @returns {object}
|
|
226
221
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
// bitmask constants to check for flipped & rotated tiles
|
|
3
|
-
|
|
3
|
+
const TMX_CLEAR_BIT_MASK = ~(0x80000000 | 0x40000000 | 0x20000000);
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc
|
|
@@ -17,7 +17,6 @@ class TMXTilesetGroup {
|
|
|
17
17
|
* add a tileset to the tileset group
|
|
18
18
|
* @name TMXTilesetGroup#add
|
|
19
19
|
* @public
|
|
20
|
-
* @function
|
|
21
20
|
* @param {TMXTileset} tileset
|
|
22
21
|
*/
|
|
23
22
|
add(tileset) {
|
|
@@ -29,7 +28,6 @@ class TMXTilesetGroup {
|
|
|
29
28
|
* return the tileset at the specified index
|
|
30
29
|
* @name TMXTilesetGroup#getTilesetByIndex
|
|
31
30
|
* @public
|
|
32
|
-
* @function
|
|
33
31
|
* @param {number} i
|
|
34
32
|
* @returns {TMXTileset} corresponding tileset
|
|
35
33
|
*/
|
|
@@ -42,7 +40,6 @@ class TMXTilesetGroup {
|
|
|
42
40
|
* will throw an exception if no matching tileset is found
|
|
43
41
|
* @name TMXTilesetGroup#getTilesetByGid
|
|
44
42
|
* @public
|
|
45
|
-
* @function
|
|
46
43
|
* @param {number} gid
|
|
47
44
|
* @returns {TMXTileset} corresponding tileset
|
|
48
45
|
*/
|
|
@@ -48,7 +48,7 @@ function setTMXValue(name, type, value) {
|
|
|
48
48
|
match = value.split(/^eval:/i)[1];
|
|
49
49
|
try {
|
|
50
50
|
// eslint-disable-next-line
|
|
51
|
-
value =
|
|
51
|
+
value = Function("'use strict';return (" + match + ")")();
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
54
|
throw new Error("Unable to evaluate: " + match);
|
|
@@ -98,7 +98,6 @@ function parseAttributes(obj, elt) {
|
|
|
98
98
|
/**
|
|
99
99
|
* decompress zlib/gzip data (NOT IMPLEMENTED)
|
|
100
100
|
* @ignore
|
|
101
|
-
* @function
|
|
102
101
|
* @name decompress
|
|
103
102
|
* @param {number[]} data Array of bytes
|
|
104
103
|
* @param {string} format compressed data format ("gzip","zlib")
|
|
@@ -110,7 +109,6 @@ export function decompress() {
|
|
|
110
109
|
/**
|
|
111
110
|
* Decode a CSV encoded array into a binary array
|
|
112
111
|
* @ignore
|
|
113
|
-
* @function
|
|
114
112
|
* @name decodeCSV
|
|
115
113
|
* @param {string} input CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
116
114
|
* @returns {number[]} Decoded data
|
|
@@ -128,7 +126,6 @@ export function decodeCSV(input) {
|
|
|
128
126
|
/**
|
|
129
127
|
* Decode a base64 encoded string into a byte array
|
|
130
128
|
* @ignore
|
|
131
|
-
* @function
|
|
132
129
|
* @name decodeBase64AsArray
|
|
133
130
|
* @param {string} input Base64 encoded data
|
|
134
131
|
* @param {number} [bytes] number of bytes per array entry
|
|
@@ -6,13 +6,13 @@ import TMXLayer from "./../TMXLayer.js";
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// scope global var & constants
|
|
9
|
-
|
|
9
|
+
const offsetsStaggerX = [
|
|
10
10
|
{x: 0, y: 0},
|
|
11
11
|
{x: + 1, y: - 1},
|
|
12
12
|
{x: + 1, y: 0},
|
|
13
13
|
{x: + 2, y: 0}
|
|
14
14
|
];
|
|
15
|
-
|
|
15
|
+
const offsetsStaggerY = [
|
|
16
16
|
{x: 0, y: 0},
|
|
17
17
|
{x: - 1, y: + 1},
|
|
18
18
|
{x: 0, y: + 1},
|
|
@@ -81,7 +81,6 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
81
81
|
* return the bounding rect for this map renderer
|
|
82
82
|
* @name TMXHexagonalRenderer#getBounds
|
|
83
83
|
* @public
|
|
84
|
-
* @function
|
|
85
84
|
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
86
85
|
* @returns {Bounds}
|
|
87
86
|
*/
|
|
@@ -41,7 +41,6 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
41
41
|
* return the bounding rect for this map renderer
|
|
42
42
|
* @name TMXIsometricRenderer#getBounds
|
|
43
43
|
* @public
|
|
44
|
-
* @function
|
|
45
44
|
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
46
45
|
* @returns {Bounds}
|
|
47
46
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import pool from "./../../../system/pooling.js";
|
|
4
4
|
import TMXLayer from "./../TMXLayer.js";
|
|
5
|
-
import Bounds from "./../../../physics/
|
|
5
|
+
import Bounds from "./../../../physics/bounds.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @classdesc
|
|
@@ -27,7 +27,6 @@ class TMXRenderer {
|
|
|
27
27
|
* return true if the renderer can render the specified map or layer
|
|
28
28
|
* @name TMXRenderer#canRender
|
|
29
29
|
* @public
|
|
30
|
-
* @function
|
|
31
30
|
* @param {TMXTileMap|TMXLayer} component TMX Map or Layer
|
|
32
31
|
* @returns {boolean}
|
|
33
32
|
*/
|
|
@@ -48,7 +47,6 @@ class TMXRenderer {
|
|
|
48
47
|
* return the bounding rect for this map renderer
|
|
49
48
|
* @name TMXRenderer#getBounds
|
|
50
49
|
* @public
|
|
51
|
-
* @function
|
|
52
50
|
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
53
51
|
* @returns {Bounds}
|
|
54
52
|
*/
|
|
@@ -66,7 +64,6 @@ class TMXRenderer {
|
|
|
66
64
|
* return the tile position corresponding to the specified pixel
|
|
67
65
|
* @name TMXRenderer#pixelToTileCoords
|
|
68
66
|
* @public
|
|
69
|
-
* @function
|
|
70
67
|
* @param {number} x X coordinate
|
|
71
68
|
* @param {number} y Y coordinate
|
|
72
69
|
* @param {Vector2d} [v] an optional vector object where to put the return values
|
|
@@ -80,7 +77,6 @@ class TMXRenderer {
|
|
|
80
77
|
* return the pixel position corresponding of the specified tile
|
|
81
78
|
* @name TMXRenderer#tileToPixelCoords
|
|
82
79
|
* @public
|
|
83
|
-
* @function
|
|
84
80
|
* @param {number} col tile horizontal position
|
|
85
81
|
* @param {number} row tile vertical position
|
|
86
82
|
* @param {Vector2d} [v] an optional vector object where to put the return values
|
|
@@ -94,7 +90,6 @@ class TMXRenderer {
|
|
|
94
90
|
* draw the given tile at the specified layer
|
|
95
91
|
* @name TMXRenderer#drawTile
|
|
96
92
|
* @public
|
|
97
|
-
* @function
|
|
98
93
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
99
94
|
* @param {number} x X coordinate where to draw the tile
|
|
100
95
|
* @param {number} y Y coordinate where to draw the tile
|
|
@@ -107,7 +102,6 @@ class TMXRenderer {
|
|
|
107
102
|
* draw the given TMX Layer for the given area
|
|
108
103
|
* @name TMXRenderer#drawTileLayer
|
|
109
104
|
* @public
|
|
110
|
-
* @function
|
|
111
105
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
112
106
|
* @param {TMXLayer} layer a TMX Layer object
|
|
113
107
|
* @param {Rect} rect the area of the layer to draw
|