melonjs 10.1.1 → 10.2.3
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 -10
- package/dist/melonjs.js +3114 -2866
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2588 -2498
- package/dist/melonjs.module.js +2694 -2479
- package/package.json +10 -11
- 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 +3 -3
- package/src/index.js +15 -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 +25 -33
- 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 +31 -27
- package/src/loader/loadingscreen.js +44 -75
- 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 +45 -51
- package/src/physics/bounds.js +36 -36
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -11
- package/src/physics/quadtree.js +18 -16
- 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 +158 -69
- package/src/renderable/renderable.js +68 -67
- 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 +8 -8
- package/src/state/state.js +56 -56
- 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 +118 -59
- 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 +85 -76
- package/src/video/texture_cache.js +11 -0
- package/src/video/video.js +31 -31
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +47 -46
- package/src/video/webgl/webgl_renderer.js +104 -104
|
@@ -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;
|
|
@@ -14,9 +14,9 @@ var TMX_FLIP_H = 0x80000000,
|
|
|
14
14
|
* @extends me.Bounds
|
|
15
15
|
* @memberOf me
|
|
16
16
|
* @constructor
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
17
|
+
* @param {number} x x index of the Tile in the map
|
|
18
|
+
* @param {number} y y index of the Tile in the map
|
|
19
|
+
* @param {number} gid tile gid
|
|
20
20
|
* @param {me.TMXTileset} tileset the corresponding tileset object
|
|
21
21
|
*/
|
|
22
22
|
class Tile extends Bounds {
|
|
@@ -42,7 +42,7 @@ class Tile extends Bounds {
|
|
|
42
42
|
/**
|
|
43
43
|
* tileset
|
|
44
44
|
* @public
|
|
45
|
-
* @type me.TMXTileset
|
|
45
|
+
* @type {me.TMXTileset}
|
|
46
46
|
* @name me.Tile#tileset
|
|
47
47
|
*/
|
|
48
48
|
this.tileset = tileset;
|
|
@@ -60,28 +60,28 @@ class Tile extends Bounds {
|
|
|
60
60
|
/**
|
|
61
61
|
* tileId
|
|
62
62
|
* @public
|
|
63
|
-
* @type
|
|
63
|
+
* @type {number}
|
|
64
64
|
* @name me.Tile#tileId
|
|
65
65
|
*/
|
|
66
66
|
this.tileId = gid;
|
|
67
67
|
/**
|
|
68
68
|
* True if the tile is flipped horizontally<br>
|
|
69
69
|
* @public
|
|
70
|
-
* @type
|
|
70
|
+
* @type {boolean}
|
|
71
71
|
* @name me.Tile#flipX
|
|
72
72
|
*/
|
|
73
73
|
this.flippedX = (this.tileId & TMX_FLIP_H) !== 0;
|
|
74
74
|
/**
|
|
75
75
|
* True if the tile is flipped vertically<br>
|
|
76
76
|
* @public
|
|
77
|
-
* @type
|
|
77
|
+
* @type {boolean}
|
|
78
78
|
* @name me.Tile#flippedY
|
|
79
79
|
*/
|
|
80
80
|
this.flippedY = (this.tileId & TMX_FLIP_V) !== 0;
|
|
81
81
|
/**
|
|
82
82
|
* True if the tile is flipped anti-diagonally<br>
|
|
83
83
|
* @public
|
|
84
|
-
* @type
|
|
84
|
+
* @type {boolean}
|
|
85
85
|
* @name me.Tile#flippedAD
|
|
86
86
|
*/
|
|
87
87
|
this.flippedAD = (this.tileId & TMX_FLIP_AD) !== 0;
|
|
@@ -89,7 +89,7 @@ class Tile extends Bounds {
|
|
|
89
89
|
/**
|
|
90
90
|
* Global flag that indicates if the tile is flipped<br>
|
|
91
91
|
* @public
|
|
92
|
-
* @type
|
|
92
|
+
* @type {boolean}
|
|
93
93
|
* @name me.Tile#flipped
|
|
94
94
|
*/
|
|
95
95
|
this.flipped = this.flippedX || this.flippedY || this.flippedAD;
|
|
@@ -108,7 +108,6 @@ class Tile extends Bounds {
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* set the transformation matrix for this tile
|
|
111
|
-
* @return {me.Matrix2d) a transformation matrix
|
|
112
111
|
* @ignore
|
|
113
112
|
*/
|
|
114
113
|
setTileTransform(transform) {
|
|
@@ -135,8 +134,8 @@ class Tile extends Bounds {
|
|
|
135
134
|
* @name me.Tile#getRenderable
|
|
136
135
|
* @public
|
|
137
136
|
* @function
|
|
138
|
-
* @param {
|
|
139
|
-
* @
|
|
137
|
+
* @param {object} [settings] see {@link me.Sprite}
|
|
138
|
+
* @returns {me.Renderable} a me.Sprite object
|
|
140
139
|
*/
|
|
141
140
|
getRenderable(settings) {
|
|
142
141
|
var renderable;
|
|
@@ -106,8 +106,8 @@ function readObjectGroup(map, data, z) {
|
|
|
106
106
|
* @class TMXTileMap
|
|
107
107
|
* @memberOf me
|
|
108
108
|
* @constructor
|
|
109
|
-
* @param {
|
|
110
|
-
* @param {
|
|
109
|
+
* @param {string} levelId name of TMX map
|
|
110
|
+
* @param {object} data TMX map in JSON format
|
|
111
111
|
* @example
|
|
112
112
|
* // create a new level object based on the TMX JSON object
|
|
113
113
|
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
@@ -128,7 +128,7 @@ export default class TMXTileMap {
|
|
|
128
128
|
/**
|
|
129
129
|
* name of the tilemap
|
|
130
130
|
* @public
|
|
131
|
-
* @type {
|
|
131
|
+
* @type {string}
|
|
132
132
|
* @name me.TMXTileMap#name
|
|
133
133
|
*/
|
|
134
134
|
this.name = levelId;
|
|
@@ -136,14 +136,14 @@ export default class TMXTileMap {
|
|
|
136
136
|
/**
|
|
137
137
|
* width of the tilemap in tiles
|
|
138
138
|
* @public
|
|
139
|
-
* @type {
|
|
139
|
+
* @type {number}
|
|
140
140
|
* @name me.TMXTileMap#cols
|
|
141
141
|
*/
|
|
142
142
|
this.cols = +data.width;
|
|
143
143
|
/**
|
|
144
144
|
* height of the tilemap in tiles
|
|
145
145
|
* @public
|
|
146
|
-
* @type {
|
|
146
|
+
* @type {number}
|
|
147
147
|
* @name me.TMXTileMap#rows
|
|
148
148
|
*/
|
|
149
149
|
this.rows = +data.height;
|
|
@@ -151,7 +151,7 @@ export default class TMXTileMap {
|
|
|
151
151
|
/**
|
|
152
152
|
* Tile width
|
|
153
153
|
* @public
|
|
154
|
-
* @type {
|
|
154
|
+
* @type {number}
|
|
155
155
|
* @name me.TMXTileMap#tilewidth
|
|
156
156
|
*/
|
|
157
157
|
this.tilewidth = +data.tilewidth;
|
|
@@ -159,7 +159,7 @@ export default class TMXTileMap {
|
|
|
159
159
|
/**
|
|
160
160
|
* Tile height
|
|
161
161
|
* @public
|
|
162
|
-
* @type {
|
|
162
|
+
* @type {number}
|
|
163
163
|
* @name me.TMXTileMap#tileheight
|
|
164
164
|
*/
|
|
165
165
|
this.tileheight = +data.tileheight;
|
|
@@ -167,7 +167,7 @@ export default class TMXTileMap {
|
|
|
167
167
|
/**
|
|
168
168
|
* is the map an infinite map
|
|
169
169
|
* @public
|
|
170
|
-
* @type {
|
|
170
|
+
* @type {number}
|
|
171
171
|
* @default 0
|
|
172
172
|
* @name me.TMXTileMap#infinite
|
|
173
173
|
*/
|
|
@@ -176,17 +176,17 @@ export default class TMXTileMap {
|
|
|
176
176
|
/**
|
|
177
177
|
* the map orientation type. melonJS supports “orthogonal”, “isometric”, “staggered” and “hexagonal”.
|
|
178
178
|
* @public
|
|
179
|
-
* @type {
|
|
179
|
+
* @type {string}
|
|
180
180
|
* @default "orthogonal"
|
|
181
181
|
* @name me.TMXTileMap#orientation
|
|
182
182
|
*/
|
|
183
183
|
this.orientation = data.orientation;
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
* the order in which tiles on orthogonal tile layers are rendered.
|
|
187
|
+
* (valid values are "left-down", "left-up", "right-down", "right-up")
|
|
188
188
|
* @public
|
|
189
|
-
* @type {
|
|
189
|
+
* @type {string}
|
|
190
190
|
* @default "right-down"
|
|
191
191
|
* @name me.TMXTileMap#renderorder
|
|
192
192
|
*/
|
|
@@ -195,7 +195,7 @@ export default class TMXTileMap {
|
|
|
195
195
|
/**
|
|
196
196
|
* the TMX format version
|
|
197
197
|
* @public
|
|
198
|
-
* @type {
|
|
198
|
+
* @type {string}
|
|
199
199
|
* @name me.TMXTileMap#version
|
|
200
200
|
*/
|
|
201
201
|
this.version = data.version;
|
|
@@ -203,7 +203,7 @@ export default class TMXTileMap {
|
|
|
203
203
|
/**
|
|
204
204
|
* The Tiled version used to save the file (since Tiled 1.0.1).
|
|
205
205
|
* @public
|
|
206
|
-
* @type {
|
|
206
|
+
* @type {string}
|
|
207
207
|
* @name me.TMXTileMap#tiledversion
|
|
208
208
|
*/
|
|
209
209
|
this.tiledversion = data.tiledversion;
|
|
@@ -261,7 +261,7 @@ export default class TMXTileMap {
|
|
|
261
261
|
* @memberOf me.TMXTileMap
|
|
262
262
|
* @public
|
|
263
263
|
* @function
|
|
264
|
-
* @
|
|
264
|
+
* @returns {me.TMXRenderer} a TMX renderer
|
|
265
265
|
*/
|
|
266
266
|
getRenderer() {
|
|
267
267
|
if ((typeof(this.renderer) === "undefined") || (!this.renderer.canRender(this))) {
|
|
@@ -275,7 +275,7 @@ export default class TMXTileMap {
|
|
|
275
275
|
* @name me.TMXRenderer#getBounds
|
|
276
276
|
* @public
|
|
277
277
|
* @function
|
|
278
|
-
* @
|
|
278
|
+
* @returns {me.Bounds}
|
|
279
279
|
*/
|
|
280
280
|
getBounds() {
|
|
281
281
|
// calculated in the constructor
|
|
@@ -369,7 +369,7 @@ export default class TMXTileMap {
|
|
|
369
369
|
* @name me.TMXTileMap#addTo
|
|
370
370
|
* @public
|
|
371
371
|
* @function
|
|
372
|
-
* @param {me.Container} target container
|
|
372
|
+
* @param {me.Container} container target container
|
|
373
373
|
* @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
|
|
374
374
|
* @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.
|
|
375
375
|
* @example
|
|
@@ -404,8 +404,10 @@ export default class TMXTileMap {
|
|
|
404
404
|
// sort everything (recursively)
|
|
405
405
|
container.sort(true);
|
|
406
406
|
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
/**
|
|
408
|
+
* callback funtion for the viewport resize event
|
|
409
|
+
* @ignore
|
|
410
|
+
*/
|
|
409
411
|
function _setBounds(width, height) {
|
|
410
412
|
// adjust the viewport bounds if level is smaller
|
|
411
413
|
viewport.setBounds(
|
|
@@ -442,7 +444,7 @@ export default class TMXTileMap {
|
|
|
442
444
|
* @function
|
|
443
445
|
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
444
446
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
445
|
-
* @
|
|
447
|
+
* @returns {me.Renderable[]} Array of Objects
|
|
446
448
|
*/
|
|
447
449
|
getObjects(flatten) {
|
|
448
450
|
var objects = [];
|
|
@@ -589,7 +591,7 @@ export default class TMXTileMap {
|
|
|
589
591
|
* @name me.TMXTileMap#getLayers
|
|
590
592
|
* @public
|
|
591
593
|
* @function
|
|
592
|
-
* @
|
|
594
|
+
* @returns {me.TMXLayer[]} Array of Layers
|
|
593
595
|
*/
|
|
594
596
|
getLayers() {
|
|
595
597
|
// parse the map for objects
|
|
@@ -10,7 +10,7 @@ import loader from "./../../loader/loader.js";
|
|
|
10
10
|
* @class TMXTileset
|
|
11
11
|
* @memberOf me
|
|
12
12
|
* @constructor
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
14
14
|
*/
|
|
15
15
|
export default class TMXTileset {
|
|
16
16
|
|
|
@@ -51,7 +51,7 @@ export default class TMXTileset {
|
|
|
51
51
|
/**
|
|
52
52
|
* Tileset contains animated tiles
|
|
53
53
|
* @public
|
|
54
|
-
* @type
|
|
54
|
+
* @type {boolean}
|
|
55
55
|
* @name me.TMXTileset#isAnimated
|
|
56
56
|
*/
|
|
57
57
|
this.isAnimated = false;
|
|
@@ -59,7 +59,7 @@ export default class TMXTileset {
|
|
|
59
59
|
/**
|
|
60
60
|
* true if the tileset is a "Collection of Image" Tileset
|
|
61
61
|
* @public
|
|
62
|
-
* @type
|
|
62
|
+
* @type {boolean}
|
|
63
63
|
* @name me.TMXTileset#isCollection
|
|
64
64
|
*/
|
|
65
65
|
this.isCollection = false;
|
|
@@ -67,7 +67,7 @@ export default class TMXTileset {
|
|
|
67
67
|
/**
|
|
68
68
|
* Tileset animations
|
|
69
69
|
* @private
|
|
70
|
-
* @type Map
|
|
70
|
+
* @type {Map}
|
|
71
71
|
* @name me.TMXTileset#animations
|
|
72
72
|
*/
|
|
73
73
|
this.animations = new Map();
|
|
@@ -75,7 +75,7 @@ export default class TMXTileset {
|
|
|
75
75
|
/**
|
|
76
76
|
* Remember the last update timestamp to prevent too many animation updates
|
|
77
77
|
* @private
|
|
78
|
-
* @type Map
|
|
78
|
+
* @type {Map}
|
|
79
79
|
* @name me.TMXTileset#_lastUpdate
|
|
80
80
|
*/
|
|
81
81
|
this._lastUpdate = 0;
|
|
@@ -173,8 +173,8 @@ export default class TMXTileset {
|
|
|
173
173
|
* @name me.TMXTileset#getTileImage
|
|
174
174
|
* @public
|
|
175
175
|
* @function
|
|
176
|
-
* @param {
|
|
177
|
-
* @
|
|
176
|
+
* @param {number} gid
|
|
177
|
+
* @returns {Image} corresponding image or undefined
|
|
178
178
|
*/
|
|
179
179
|
getTileImage(gid) {
|
|
180
180
|
return this.imageCollection[gid];
|
|
@@ -196,8 +196,8 @@ export default class TMXTileset {
|
|
|
196
196
|
* @name me.TMXTileset#contains
|
|
197
197
|
* @public
|
|
198
198
|
* @function
|
|
199
|
-
* @param {
|
|
200
|
-
* @
|
|
199
|
+
* @param {number} gid
|
|
200
|
+
* @returns {boolean}
|
|
201
201
|
*/
|
|
202
202
|
contains(gid) {
|
|
203
203
|
return gid >= this.firstgid && gid <= this.lastgid;
|
|
@@ -208,8 +208,8 @@ export default class TMXTileset {
|
|
|
208
208
|
* @name me.TMXTileset#getViewTileId
|
|
209
209
|
* @public
|
|
210
210
|
* @function
|
|
211
|
-
* @param {
|
|
212
|
-
* @
|
|
211
|
+
* @param {number} gid Global tile ID
|
|
212
|
+
* @returns {number} View tile ID
|
|
213
213
|
*/
|
|
214
214
|
getViewTileId(gid) {
|
|
215
215
|
var localId = gid - this.firstgid;
|
|
@@ -227,8 +227,8 @@ export default class TMXTileset {
|
|
|
227
227
|
* @name me.TMXTileset#getTileProperties
|
|
228
228
|
* @public
|
|
229
229
|
* @function
|
|
230
|
-
* @param {
|
|
231
|
-
* @
|
|
230
|
+
* @param {number} tileId
|
|
231
|
+
* @returns {object}
|
|
232
232
|
*/
|
|
233
233
|
getTileProperties(tileId) {
|
|
234
234
|
return this.TileProperties[tileId];
|
|
@@ -33,8 +33,8 @@ export default class TMXTilesetGroup {
|
|
|
33
33
|
* @name me.TMXTilesetGroup#getTilesetByIndex
|
|
34
34
|
* @public
|
|
35
35
|
* @function
|
|
36
|
-
* @param {
|
|
37
|
-
* @
|
|
36
|
+
* @param {number} i
|
|
37
|
+
* @returns {me.TMXTileset} corresponding tileset
|
|
38
38
|
*/
|
|
39
39
|
getTilesetByIndex(i) {
|
|
40
40
|
return this.tilesets[i];
|
|
@@ -46,8 +46,8 @@ export default class TMXTilesetGroup {
|
|
|
46
46
|
* @name me.TMXTilesetGroup#getTilesetByGid
|
|
47
47
|
* @public
|
|
48
48
|
* @function
|
|
49
|
-
* @param {
|
|
50
|
-
* @
|
|
49
|
+
* @param {number} gid
|
|
50
|
+
* @returns {me.TMXTileset} corresponding tileset
|
|
51
51
|
*/
|
|
52
52
|
getTilesetByGid(gid) {
|
|
53
53
|
var invalidRange = -1;
|