melonjs 10.2.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
package/src/lang/deprecated.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
import device from "./../system/device.js";
|
|
2
|
+
import { requestPointerLock, exitPointerLock } from "./../input/input.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* placeholder for all deprecated classes and corresponding alias for backward compatibility
|
|
3
|
-
* @namespace deprecated
|
|
4
|
-
* @memberOf me
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* display a deprecation warning in the console
|
|
9
|
-
* @
|
|
10
|
-
* @function
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
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
|
|
10
|
+
* @ignore
|
|
11
|
+
* @param {string} deprecated deprecated class,function or property name
|
|
12
|
+
* @param {string} replacement the replacement class, function, or property name
|
|
13
|
+
* @param {string} version the version since when the lass,function or property is deprecated
|
|
16
14
|
*/
|
|
17
15
|
export function warning(deprecated, replacement, version) {
|
|
18
16
|
var msg = "melonJS: %s is deprecated since version %s, please use %s";
|
|
@@ -42,17 +40,30 @@ export function warning(deprecated, replacement, version) {
|
|
|
42
40
|
if (console.groupCollapsed) {
|
|
43
41
|
console.groupEnd();
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
43
|
};
|
|
48
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @public
|
|
47
|
+
* @type {Function}
|
|
48
|
+
* @name turnOnPointerLock
|
|
49
|
+
* @memberof me.device
|
|
50
|
+
* @deprecated since 10.3.0
|
|
51
|
+
* @see me.input.requestPointerLock
|
|
52
|
+
*/
|
|
53
|
+
device.turnOnPointerLock = function () {
|
|
54
|
+
warning("me.device.turnOnPointerLock()", "me.input.requestPointerLock()", "10.3.0");
|
|
55
|
+
return requestPointerLock();
|
|
56
|
+
};
|
|
49
57
|
|
|
50
58
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
54
|
-
* @
|
|
59
|
+
* @public
|
|
60
|
+
* @type {Function}
|
|
61
|
+
* @name turnOffPointerLock
|
|
62
|
+
* @memberof me.device
|
|
63
|
+
* @deprecated since 10.3.0
|
|
64
|
+
* @see me.input.exitPointerLock
|
|
55
65
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
device.turnOffPointerLock = function () {
|
|
67
|
+
warning("me.device.turnOffPointerLock()", "me.input.exitPointerLock()", "10.3.0");
|
|
68
|
+
return exitPointerLock();
|
|
69
|
+
};
|
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();
|
|
@@ -46,10 +49,10 @@ function safeLoadLevel(levelId, options, restart) {
|
|
|
46
49
|
/**
|
|
47
50
|
* Load a TMX level
|
|
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
|
|
@@ -73,7 +76,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
|
|
|
73
76
|
/**
|
|
74
77
|
* a level manager. once ressources loaded, the level manager contains all references of defined levels.
|
|
75
78
|
* @namespace level
|
|
76
|
-
* @
|
|
79
|
+
* @memberof me
|
|
77
80
|
*/
|
|
78
81
|
|
|
79
82
|
var level = {
|
|
@@ -81,13 +84,13 @@ var level = {
|
|
|
81
84
|
/**
|
|
82
85
|
* add a level into the game manager (usually called by the preloader)
|
|
83
86
|
* @name add
|
|
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) {
|
|
@@ -120,15 +123,16 @@ var level = {
|
|
|
120
123
|
* load a level into the game manager<br>
|
|
121
124
|
* (will also create all level defined entities, etc..)
|
|
122
125
|
* @name load
|
|
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
|
|
@@ -193,10 +197,10 @@ var level = {
|
|
|
193
197
|
/**
|
|
194
198
|
* return the current level id<br>
|
|
195
199
|
* @name getCurrentLevelId
|
|
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];
|
|
@@ -207,10 +211,10 @@ var level = {
|
|
|
207
211
|
* for a reference to the live instantiated level,
|
|
208
212
|
* rather use the container in which it was loaded (e.g. me.game.world)
|
|
209
213
|
* @name getCurrentLevel
|
|
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()];
|
|
@@ -219,13 +223,14 @@ var level = {
|
|
|
219
223
|
/**
|
|
220
224
|
* reload the current level
|
|
221
225
|
* @name reload
|
|
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
|
|
@@ -236,13 +241,14 @@ var level = {
|
|
|
236
241
|
/**
|
|
237
242
|
* load the next level
|
|
238
243
|
* @name next
|
|
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
|
|
@@ -257,13 +263,14 @@ var level = {
|
|
|
257
263
|
/**
|
|
258
264
|
* load the previous level<br>
|
|
259
265
|
* @name previous
|
|
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
|
|
@@ -278,9 +285,10 @@ var level = {
|
|
|
278
285
|
/**
|
|
279
286
|
* return the amount of level preloaded
|
|
280
287
|
* @name levelCount
|
|
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;
|
|
@@ -8,7 +8,6 @@ import { clamp } from "./../../math/math.js";
|
|
|
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
10
|
* @class TMXGroup
|
|
11
|
-
* @constructor
|
|
12
11
|
* @ignore
|
|
13
12
|
*/
|
|
14
13
|
export default class TMXGroup {
|
|
@@ -18,45 +17,45 @@ export default class TMXGroup {
|
|
|
18
17
|
/**
|
|
19
18
|
* group name
|
|
20
19
|
* @public
|
|
21
|
-
* @type
|
|
20
|
+
* @type {string}
|
|
22
21
|
* @name name
|
|
23
|
-
* @
|
|
22
|
+
* @memberof me.TMXGroup
|
|
24
23
|
*/
|
|
25
24
|
this.name = data.name;
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* group width
|
|
29
28
|
* @public
|
|
30
|
-
* @type
|
|
29
|
+
* @type {number}
|
|
31
30
|
* @name width
|
|
32
|
-
* @
|
|
31
|
+
* @memberof me.TMXGroup
|
|
33
32
|
*/
|
|
34
33
|
this.width = data.width || 0;
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* group height
|
|
38
37
|
* @public
|
|
39
|
-
* @type
|
|
38
|
+
* @type {number}
|
|
40
39
|
* @name height
|
|
41
|
-
* @
|
|
40
|
+
* @memberof me.TMXGroup
|
|
42
41
|
*/
|
|
43
42
|
this.height = data.height || 0;
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* tint color
|
|
47
46
|
* @public
|
|
48
|
-
* @type
|
|
47
|
+
* @type {string}
|
|
49
48
|
* @name tintcolor
|
|
50
|
-
* @
|
|
49
|
+
* @memberof me.TMXGroup
|
|
51
50
|
*/
|
|
52
51
|
this.tintcolor = data.tintcolor;
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
54
|
* group z order
|
|
56
55
|
* @public
|
|
57
|
-
* @type
|
|
56
|
+
* @type {number}
|
|
58
57
|
* @name z
|
|
59
|
-
* @
|
|
58
|
+
* @memberof me.TMXGroup
|
|
60
59
|
*/
|
|
61
60
|
this.z = z;
|
|
62
61
|
|
|
@@ -64,9 +63,9 @@ export default class TMXGroup {
|
|
|
64
63
|
* group objects list definition
|
|
65
64
|
* @see me.TMXObject
|
|
66
65
|
* @public
|
|
67
|
-
* @type
|
|
66
|
+
* @type {object[]}
|
|
68
67
|
* @name name
|
|
69
|
-
* @
|
|
68
|
+
* @memberof me.TMXGroup
|
|
70
69
|
*/
|
|
71
70
|
this.objects = [];
|
|
72
71
|
|
|
@@ -66,16 +66,15 @@ function preRenderLayer(layer, renderer) {
|
|
|
66
66
|
* a TMX Tile Layer Object
|
|
67
67
|
* Tiled QT 0.7.x format
|
|
68
68
|
* @class
|
|
69
|
-
* @
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {String} orientation "isometric" or "orthogonal"
|
|
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"
|
|
77
76
|
* @param {me.TMXTilesetGroup} tilesets tileset as defined in Tiled
|
|
78
|
-
* @param {
|
|
77
|
+
* @param {number} z z-index position
|
|
79
78
|
*/
|
|
80
79
|
class TMXLayer extends Renderable {
|
|
81
80
|
/**
|
|
@@ -95,7 +94,7 @@ class TMXLayer extends Renderable {
|
|
|
95
94
|
/**
|
|
96
95
|
* The Layer corresponding Tilesets
|
|
97
96
|
* @public
|
|
98
|
-
* @type me.TMXTilesetGroup
|
|
97
|
+
* @type {me.TMXTilesetGroup}
|
|
99
98
|
* @name me.TMXLayer#tilesets
|
|
100
99
|
*/
|
|
101
100
|
this.tilesets = tilesets;
|
|
@@ -118,7 +117,7 @@ class TMXLayer extends Renderable {
|
|
|
118
117
|
/**
|
|
119
118
|
* All animated tilesets in this layer
|
|
120
119
|
* @ignore
|
|
121
|
-
* @type
|
|
120
|
+
* @type {me.TMXTileset[]}
|
|
122
121
|
* @name me.TMXLayer#animatedTilesets
|
|
123
122
|
*/
|
|
124
123
|
this.animatedTilesets = [];
|
|
@@ -126,7 +125,7 @@ class TMXLayer extends Renderable {
|
|
|
126
125
|
/**
|
|
127
126
|
* Layer contains tileset animations
|
|
128
127
|
* @public
|
|
129
|
-
* @type
|
|
128
|
+
* @type {boolean}
|
|
130
129
|
* @name me.TMXLayer#isAnimated
|
|
131
130
|
*/
|
|
132
131
|
this.isAnimated = false;
|
|
@@ -135,7 +134,7 @@ class TMXLayer extends Renderable {
|
|
|
135
134
|
* the order in which tiles on orthogonal tile layers are rendered.
|
|
136
135
|
* (valid values are "left-down", "left-up", "right-down", "right-up")
|
|
137
136
|
* @public
|
|
138
|
-
* @type {
|
|
137
|
+
* @type {string}
|
|
139
138
|
* @default "right-down"
|
|
140
139
|
* @name me.TMXLayer#renderorder
|
|
141
140
|
*/
|
|
@@ -243,7 +242,7 @@ class TMXLayer extends Renderable {
|
|
|
243
242
|
/**
|
|
244
243
|
* Set the TMX renderer for this layer object
|
|
245
244
|
* @name setRenderer
|
|
246
|
-
* @
|
|
245
|
+
* @memberof me.TMXLayer
|
|
247
246
|
* @public
|
|
248
247
|
* @function
|
|
249
248
|
* @param {me.TMXRenderer} renderer
|
|
@@ -259,10 +258,10 @@ class TMXLayer extends Renderable {
|
|
|
259
258
|
/**
|
|
260
259
|
* Return the layer current renderer object
|
|
261
260
|
* @name getRenderer
|
|
262
|
-
* @
|
|
261
|
+
* @memberof me.TMXLayer
|
|
263
262
|
* @public
|
|
264
263
|
* @function
|
|
265
|
-
* @
|
|
264
|
+
* @returns {me.TMXRenderer} renderer
|
|
266
265
|
*/
|
|
267
266
|
getRenderer() {
|
|
268
267
|
return this.renderer;
|
|
@@ -272,12 +271,12 @@ class TMXLayer extends Renderable {
|
|
|
272
271
|
/**
|
|
273
272
|
* Return the TileId of the Tile at the specified position
|
|
274
273
|
* @name getTileId
|
|
275
|
-
* @
|
|
274
|
+
* @memberof me.TMXLayer
|
|
276
275
|
* @public
|
|
277
276
|
* @function
|
|
278
|
-
* @param {
|
|
279
|
-
* @param {
|
|
280
|
-
* @
|
|
277
|
+
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
278
|
+
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
279
|
+
* @returns {number} TileId or null if there is no Tile at the given position
|
|
281
280
|
*/
|
|
282
281
|
getTileId(x, y) {
|
|
283
282
|
var tile = this.getTile(x, y);
|
|
@@ -287,12 +286,12 @@ class TMXLayer extends Renderable {
|
|
|
287
286
|
/**
|
|
288
287
|
* Return the Tile object at the specified position
|
|
289
288
|
* @name getTile
|
|
290
|
-
* @
|
|
289
|
+
* @memberof me.TMXLayer
|
|
291
290
|
* @public
|
|
292
291
|
* @function
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {
|
|
295
|
-
* @
|
|
292
|
+
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
293
|
+
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
294
|
+
* @returns {me.Tile} corresponding tile or null if there is no defined tile at the coordinate or if outside of the layer bounds
|
|
296
295
|
* @example
|
|
297
296
|
* // get the TMX Map Layer called "Front layer"
|
|
298
297
|
* var layer = me.game.world.getChildByName("Front Layer")[0];
|
|
@@ -313,13 +312,13 @@ class TMXLayer extends Renderable {
|
|
|
313
312
|
/**
|
|
314
313
|
* assign the given Tile object to the specified position
|
|
315
314
|
* @name getTile
|
|
316
|
-
* @
|
|
315
|
+
* @memberof me.TMXLayer
|
|
317
316
|
* @public
|
|
318
317
|
* @function
|
|
319
|
-
* @
|
|
320
|
-
* @param {
|
|
321
|
-
* @param {
|
|
322
|
-
* @
|
|
318
|
+
* @param {me.Tile} tile the tile object to be assigned
|
|
319
|
+
* @param {number} x x coordinate (in world/pixels coordinates)
|
|
320
|
+
* @param {number} y y coordinate (in world/pixels coordinates)
|
|
321
|
+
* @returns {me.Tile} the tile object
|
|
323
322
|
*/
|
|
324
323
|
setTile(tile, x, y) {
|
|
325
324
|
this.layerData[x][y] = tile;
|
|
@@ -329,13 +328,13 @@ class TMXLayer extends Renderable {
|
|
|
329
328
|
/**
|
|
330
329
|
* return a new the Tile object corresponding to the given tile id
|
|
331
330
|
* @name setTile
|
|
332
|
-
* @
|
|
331
|
+
* @memberof me.TMXLayer
|
|
333
332
|
* @public
|
|
334
333
|
* @function
|
|
335
|
-
* @param {
|
|
336
|
-
* @param {
|
|
337
|
-
* @param {
|
|
338
|
-
* @
|
|
334
|
+
* @param {number} tileId tileId
|
|
335
|
+
* @param {number} x X coordinate (in world/pixels coordinates)
|
|
336
|
+
* @param {number} y Y coordinate (in world/pixels coordinates)
|
|
337
|
+
* @returns {me.Tile} the tile object
|
|
339
338
|
*/
|
|
340
339
|
getTileById(tileId, x, y) {
|
|
341
340
|
if (!this.tileset.contains(tileId)) {
|
|
@@ -348,13 +347,13 @@ class TMXLayer extends Renderable {
|
|
|
348
347
|
/**
|
|
349
348
|
* Return the Tile object at the specified tile coordinates
|
|
350
349
|
* @name cellAt
|
|
351
|
-
* @
|
|
350
|
+
* @memberof me.TMXLayer
|
|
352
351
|
* @public
|
|
353
352
|
* @function
|
|
354
|
-
* @param {
|
|
355
|
-
* @param {
|
|
356
|
-
* @param {
|
|
357
|
-
* @
|
|
353
|
+
* @param {number} x x position of the tile (in Tile unit)
|
|
354
|
+
* @param {number} y x position of the tile (in Tile unit)
|
|
355
|
+
* @param {number} [boundsCheck=true] check first if within the layer bounds
|
|
356
|
+
* @returns {me.Tile} corresponding tile or null if there is no defined tile at the position or if outside of the layer bounds
|
|
358
357
|
* @example
|
|
359
358
|
* // return the first tile at offset 0, 0
|
|
360
359
|
* var tile = layer.cellAt(0, 0);
|
|
@@ -375,11 +374,11 @@ class TMXLayer extends Renderable {
|
|
|
375
374
|
/**
|
|
376
375
|
* clear the tile at the specified position
|
|
377
376
|
* @name clearTile
|
|
378
|
-
* @
|
|
377
|
+
* @memberof me.TMXLayer
|
|
379
378
|
* @public
|
|
380
379
|
* @function
|
|
381
|
-
* @param {
|
|
382
|
-
* @param {
|
|
380
|
+
* @param {number} x X coordinate (in map coordinates: row/column)
|
|
381
|
+
* @param {number} y Y coordinate (in map coordinates: row/column)
|
|
383
382
|
* @example
|
|
384
383
|
* me.game.world.getChildByType(me.TMXLayer).forEach(function(layer) {
|
|
385
384
|
* // clear all tiles at the given x,y coordinates
|