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
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import Vector2d from "./../../math/vector2.js";
|
|
2
2
|
import { applyTMXProperties } from "./TMXUtils.js";
|
|
3
3
|
import Tile from "./TMXTile.js";
|
|
4
|
-
import Ellipse from "./../../
|
|
5
|
-
import Polygon from "./../../
|
|
6
|
-
import Line from "./../../
|
|
4
|
+
import Ellipse from "./../../geometries/ellipse.js";
|
|
5
|
+
import Polygon from "./../../geometries/poly.js";
|
|
6
|
+
import Line from "./../../geometries/line.js";
|
|
7
7
|
import { degToRad } from "./../../math/math.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* a TMX Object defintion, as defined in Tiled
|
|
11
11
|
* (Object definition is translated into the virtual `me.game.world` using `me.Renderable`)
|
|
12
12
|
* @class TMXObject
|
|
13
|
-
* @constructor
|
|
14
13
|
* @ignore
|
|
15
14
|
*/
|
|
16
15
|
export default class TMXObject {
|
|
@@ -20,63 +19,63 @@ export default class TMXObject {
|
|
|
20
19
|
/**
|
|
21
20
|
* point list in JSON format
|
|
22
21
|
* @public
|
|
23
|
-
* @type
|
|
22
|
+
* @type {object[]}
|
|
24
23
|
* @name points
|
|
25
|
-
* @
|
|
24
|
+
* @memberof me.TMXObject
|
|
26
25
|
*/
|
|
27
26
|
this.points = undefined;
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* object name
|
|
31
30
|
* @public
|
|
32
|
-
* @type
|
|
31
|
+
* @type {string}
|
|
33
32
|
* @name name
|
|
34
|
-
* @
|
|
33
|
+
* @memberof me.TMXObject
|
|
35
34
|
*/
|
|
36
35
|
this.name = settings.name;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* object x position
|
|
40
39
|
* @public
|
|
41
|
-
* @type
|
|
40
|
+
* @type {number}
|
|
42
41
|
* @name x
|
|
43
|
-
* @
|
|
42
|
+
* @memberof me.TMXObject
|
|
44
43
|
*/
|
|
45
44
|
this.x = +settings.x;
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
* object y position
|
|
49
48
|
* @public
|
|
50
|
-
* @type
|
|
49
|
+
* @type {number}
|
|
51
50
|
* @name y
|
|
52
|
-
* @
|
|
51
|
+
* @memberof me.TMXObject
|
|
53
52
|
*/
|
|
54
53
|
this.y = +settings.y;
|
|
55
54
|
|
|
56
55
|
/**
|
|
57
56
|
* object z order
|
|
58
57
|
* @public
|
|
59
|
-
* @type
|
|
58
|
+
* @type {number}
|
|
60
59
|
* @name z
|
|
61
|
-
* @
|
|
60
|
+
* @memberof me.TMXObject
|
|
62
61
|
*/
|
|
63
62
|
this.z = +z;
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
65
|
* object width
|
|
67
66
|
* @public
|
|
68
|
-
* @type
|
|
67
|
+
* @type {number}
|
|
69
68
|
* @name width
|
|
70
|
-
* @
|
|
69
|
+
* @memberof me.TMXObject
|
|
71
70
|
*/
|
|
72
71
|
this.width = +settings.width || 0;
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* object height
|
|
76
75
|
* @public
|
|
77
|
-
* @type
|
|
76
|
+
* @type {number}
|
|
78
77
|
* @name height
|
|
79
|
-
* @
|
|
78
|
+
* @memberof me.TMXObject
|
|
80
79
|
*/
|
|
81
80
|
this.height = +settings.height || 0;
|
|
82
81
|
|
|
@@ -84,100 +83,100 @@ export default class TMXObject {
|
|
|
84
83
|
* object gid value
|
|
85
84
|
* when defined the object is a tiled object
|
|
86
85
|
* @public
|
|
87
|
-
* @type
|
|
86
|
+
* @type {number}
|
|
88
87
|
* @name gid
|
|
89
|
-
* @
|
|
88
|
+
* @memberof me.TMXObject
|
|
90
89
|
*/
|
|
91
90
|
this.gid = +settings.gid || null;
|
|
92
91
|
|
|
93
92
|
/**
|
|
94
93
|
* tint color
|
|
95
94
|
* @public
|
|
96
|
-
* @type
|
|
95
|
+
* @type {string}
|
|
97
96
|
* @name tintcolor
|
|
98
|
-
* @
|
|
97
|
+
* @memberof me.TMXObject
|
|
99
98
|
*/
|
|
100
99
|
this.tintcolor = settings.tintcolor;
|
|
101
100
|
|
|
102
101
|
/**
|
|
103
102
|
* object type
|
|
104
103
|
* @public
|
|
105
|
-
* @type
|
|
104
|
+
* @type {string}
|
|
106
105
|
* @name type
|
|
107
|
-
* @
|
|
106
|
+
* @memberof me.TMXObject
|
|
108
107
|
*/
|
|
109
108
|
this.type = settings.type;
|
|
110
109
|
|
|
111
110
|
/**
|
|
112
111
|
* object text
|
|
113
112
|
* @public
|
|
114
|
-
* @type
|
|
113
|
+
* @type {object}
|
|
115
114
|
* @see http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#text
|
|
116
115
|
* @name type
|
|
117
|
-
* @
|
|
116
|
+
* @memberof me.TMXObject
|
|
118
117
|
*/
|
|
119
118
|
this.type = settings.type;
|
|
120
119
|
|
|
121
120
|
/**
|
|
122
121
|
* The rotation of the object in radians clockwise (defaults to 0)
|
|
123
122
|
* @public
|
|
124
|
-
* @type
|
|
123
|
+
* @type {number}
|
|
125
124
|
* @name rotation
|
|
126
|
-
* @
|
|
125
|
+
* @memberof me.TMXObject
|
|
127
126
|
*/
|
|
128
127
|
this.rotation = degToRad(+settings.rotation || 0);
|
|
129
128
|
|
|
130
129
|
/**
|
|
131
130
|
* object unique identifier per level (Tiled 0.11.x+)
|
|
132
131
|
* @public
|
|
133
|
-
* @type
|
|
132
|
+
* @type {number}
|
|
134
133
|
* @name id
|
|
135
|
-
* @
|
|
134
|
+
* @memberof me.TMXObject
|
|
136
135
|
*/
|
|
137
136
|
this.id = +settings.id || undefined;
|
|
138
137
|
|
|
139
138
|
/**
|
|
140
139
|
* object orientation (orthogonal or isometric)
|
|
141
140
|
* @public
|
|
142
|
-
* @type
|
|
141
|
+
* @type {string}
|
|
143
142
|
* @name orientation
|
|
144
|
-
* @
|
|
143
|
+
* @memberof me.TMXObject
|
|
145
144
|
*/
|
|
146
145
|
this.orientation = map.orientation;
|
|
147
146
|
|
|
148
147
|
/**
|
|
149
148
|
* the collision shapes defined for this object
|
|
150
149
|
* @public
|
|
151
|
-
* @type
|
|
150
|
+
* @type {object[]}
|
|
152
151
|
* @name shapes
|
|
153
|
-
* @
|
|
152
|
+
* @memberof me.TMXObject
|
|
154
153
|
*/
|
|
155
154
|
this.shapes = undefined;
|
|
156
155
|
|
|
157
156
|
/**
|
|
158
157
|
* if true, the object is an Ellipse
|
|
159
158
|
* @public
|
|
160
|
-
* @type
|
|
159
|
+
* @type {boolean}
|
|
161
160
|
* @name isEllipse
|
|
162
|
-
* @
|
|
161
|
+
* @memberof me.TMXObject
|
|
163
162
|
*/
|
|
164
163
|
this.isEllipse = false;
|
|
165
164
|
|
|
166
165
|
/**
|
|
167
166
|
* if true, the object is a Polygon
|
|
168
167
|
* @public
|
|
169
|
-
* @type
|
|
168
|
+
* @type {boolean}
|
|
170
169
|
* @name isPolygon
|
|
171
|
-
* @
|
|
170
|
+
* @memberof me.TMXObject
|
|
172
171
|
*/
|
|
173
172
|
this.isPolygon = false;
|
|
174
173
|
|
|
175
174
|
/**
|
|
176
175
|
* if true, the object is a PolyLine
|
|
177
176
|
* @public
|
|
178
|
-
* @type
|
|
177
|
+
* @type {boolean}
|
|
179
178
|
* @name isPolyLine
|
|
180
|
-
* @
|
|
179
|
+
* @memberof me.TMXObject
|
|
181
180
|
*/
|
|
182
181
|
this.isPolyLine = false;
|
|
183
182
|
|
|
@@ -249,10 +248,10 @@ export default class TMXObject {
|
|
|
249
248
|
/**
|
|
250
249
|
* parses the TMX shape definition and returns a corresponding array of me.Shape object
|
|
251
250
|
* @name parseTMXShapes
|
|
252
|
-
* @
|
|
251
|
+
* @memberof me.TMXObject
|
|
253
252
|
* @private
|
|
254
253
|
* @function
|
|
255
|
-
* @
|
|
254
|
+
* @returns {me.Polygon[]|me.Line[]|me.Ellipse[]} an array of shape objects
|
|
256
255
|
*/
|
|
257
256
|
parseTMXShapes() {
|
|
258
257
|
var i = 0;
|
|
@@ -267,39 +266,46 @@ export default class TMXObject {
|
|
|
267
266
|
this.width,
|
|
268
267
|
this.height
|
|
269
268
|
)).rotate(this.rotation));
|
|
270
|
-
}
|
|
269
|
+
} else {
|
|
271
270
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
271
|
+
// add a polygon
|
|
272
|
+
if (this.isPolygon === true) {
|
|
273
|
+
var _polygon = new Polygon(0, 0, this.points);
|
|
274
|
+
// make sure it's a convex polygon
|
|
275
|
+
if (_polygon.isConvex() === false ) {
|
|
276
|
+
throw new Error("collision polygones in Tiled should be defined as Convex");
|
|
277
|
+
}
|
|
278
|
+
shapes.push(_polygon.rotate(this.rotation));
|
|
279
|
+
}
|
|
276
280
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
281
|
+
// add a polyline
|
|
282
|
+
else if (this.isPolyLine === true) {
|
|
283
|
+
var p = this.points;
|
|
284
|
+
var p1, p2;
|
|
285
|
+
var segments = p.length - 1;
|
|
286
|
+
for (i = 0; i < segments; i++) {
|
|
287
|
+
// clone the value before, as [i + 1]
|
|
288
|
+
// is reused later by the next segment
|
|
289
|
+
p1 = new Vector2d(p[i].x, p[i].y);
|
|
290
|
+
p2 = new Vector2d(p[i + 1].x, p[i + 1].y);
|
|
291
|
+
if (this.rotation !== 0) {
|
|
292
|
+
p1 = p1.rotate(this.rotation);
|
|
293
|
+
p2 = p2.rotate(this.rotation);
|
|
294
|
+
}
|
|
295
|
+
shapes.push(new Line(0, 0, [ p1, p2 ]));
|
|
290
296
|
}
|
|
291
|
-
shapes.push(new Line(0, 0, [ p1, p2 ]));
|
|
292
297
|
}
|
|
293
|
-
}
|
|
294
298
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
// it's a rectangle, returns a polygon object anyway
|
|
300
|
+
else {
|
|
301
|
+
shapes.push((new Polygon(
|
|
302
|
+
0, 0, [
|
|
303
|
+
new Vector2d(), new Vector2d(this.width, 0),
|
|
304
|
+
new Vector2d(this.width, this.height), new Vector2d(0, this.height)
|
|
305
|
+
]
|
|
306
|
+
)).rotate(this.rotation));
|
|
307
|
+
}
|
|
308
|
+
|
|
303
309
|
}
|
|
304
310
|
|
|
305
311
|
// Apply isometric projection
|
|
@@ -11,12 +11,11 @@ var TMX_FLIP_H = 0x80000000,
|
|
|
11
11
|
/**
|
|
12
12
|
* a basic tile object
|
|
13
13
|
* @class
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {Number} gid tile gid
|
|
14
|
+
* @augments me.Bounds
|
|
15
|
+
* @memberof me
|
|
16
|
+
* @param {number} x x index of the Tile in the map
|
|
17
|
+
* @param {number} y y index of the Tile in the map
|
|
18
|
+
* @param {number} gid tile gid
|
|
20
19
|
* @param {me.TMXTileset} tileset the corresponding tileset object
|
|
21
20
|
*/
|
|
22
21
|
class Tile extends Bounds {
|
|
@@ -42,7 +41,7 @@ class Tile extends Bounds {
|
|
|
42
41
|
/**
|
|
43
42
|
* tileset
|
|
44
43
|
* @public
|
|
45
|
-
* @type me.TMXTileset
|
|
44
|
+
* @type {me.TMXTileset}
|
|
46
45
|
* @name me.Tile#tileset
|
|
47
46
|
*/
|
|
48
47
|
this.tileset = tileset;
|
|
@@ -60,28 +59,28 @@ class Tile extends Bounds {
|
|
|
60
59
|
/**
|
|
61
60
|
* tileId
|
|
62
61
|
* @public
|
|
63
|
-
* @type
|
|
62
|
+
* @type {number}
|
|
64
63
|
* @name me.Tile#tileId
|
|
65
64
|
*/
|
|
66
65
|
this.tileId = gid;
|
|
67
66
|
/**
|
|
68
67
|
* True if the tile is flipped horizontally<br>
|
|
69
68
|
* @public
|
|
70
|
-
* @type
|
|
69
|
+
* @type {boolean}
|
|
71
70
|
* @name me.Tile#flipX
|
|
72
71
|
*/
|
|
73
72
|
this.flippedX = (this.tileId & TMX_FLIP_H) !== 0;
|
|
74
73
|
/**
|
|
75
74
|
* True if the tile is flipped vertically<br>
|
|
76
75
|
* @public
|
|
77
|
-
* @type
|
|
76
|
+
* @type {boolean}
|
|
78
77
|
* @name me.Tile#flippedY
|
|
79
78
|
*/
|
|
80
79
|
this.flippedY = (this.tileId & TMX_FLIP_V) !== 0;
|
|
81
80
|
/**
|
|
82
81
|
* True if the tile is flipped anti-diagonally<br>
|
|
83
82
|
* @public
|
|
84
|
-
* @type
|
|
83
|
+
* @type {boolean}
|
|
85
84
|
* @name me.Tile#flippedAD
|
|
86
85
|
*/
|
|
87
86
|
this.flippedAD = (this.tileId & TMX_FLIP_AD) !== 0;
|
|
@@ -89,7 +88,7 @@ class Tile extends Bounds {
|
|
|
89
88
|
/**
|
|
90
89
|
* Global flag that indicates if the tile is flipped<br>
|
|
91
90
|
* @public
|
|
92
|
-
* @type
|
|
91
|
+
* @type {boolean}
|
|
93
92
|
* @name me.Tile#flipped
|
|
94
93
|
*/
|
|
95
94
|
this.flipped = this.flippedX || this.flippedY || this.flippedAD;
|
|
@@ -108,7 +107,6 @@ class Tile extends Bounds {
|
|
|
108
107
|
|
|
109
108
|
/**
|
|
110
109
|
* set the transformation matrix for this tile
|
|
111
|
-
* @return {me.Matrix2d) a transformation matrix
|
|
112
110
|
* @ignore
|
|
113
111
|
*/
|
|
114
112
|
setTileTransform(transform) {
|
|
@@ -135,8 +133,8 @@ class Tile extends Bounds {
|
|
|
135
133
|
* @name me.Tile#getRenderable
|
|
136
134
|
* @public
|
|
137
135
|
* @function
|
|
138
|
-
* @param {
|
|
139
|
-
* @
|
|
136
|
+
* @param {object} [settings] see {@link me.Sprite}
|
|
137
|
+
* @returns {me.Renderable} a me.Sprite object
|
|
140
138
|
*/
|
|
141
139
|
getRenderable(settings) {
|
|
142
140
|
var renderable;
|
|
@@ -14,7 +14,7 @@ import TMXLayer from "./TMXLayer.js";
|
|
|
14
14
|
import { applyTMXProperties } from "./TMXUtils.js";
|
|
15
15
|
import Renderable from "./../../renderable/renderable.js";
|
|
16
16
|
import Container from "./../../renderable/container.js";
|
|
17
|
-
import Rect from "./../../
|
|
17
|
+
import Rect from "./../../geometries/rectangle.js";
|
|
18
18
|
|
|
19
19
|
// constant to identify the collision object layer
|
|
20
20
|
var COLLISION_GROUP = "collision";
|
|
@@ -104,10 +104,9 @@ function readObjectGroup(map, data, z) {
|
|
|
104
104
|
* a TMX Tile Map Object
|
|
105
105
|
* Tiled QT +0.7.x format
|
|
106
106
|
* @class TMXTileMap
|
|
107
|
-
* @
|
|
108
|
-
* @
|
|
109
|
-
* @param {
|
|
110
|
-
* @param {Object} data TMX map in JSON format
|
|
107
|
+
* @memberof me
|
|
108
|
+
* @param {string} levelId name of TMX map
|
|
109
|
+
* @param {object} data TMX map in JSON format
|
|
111
110
|
* @example
|
|
112
111
|
* // create a new level object based on the TMX JSON object
|
|
113
112
|
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
@@ -128,7 +127,7 @@ export default class TMXTileMap {
|
|
|
128
127
|
/**
|
|
129
128
|
* name of the tilemap
|
|
130
129
|
* @public
|
|
131
|
-
* @type {
|
|
130
|
+
* @type {string}
|
|
132
131
|
* @name me.TMXTileMap#name
|
|
133
132
|
*/
|
|
134
133
|
this.name = levelId;
|
|
@@ -136,14 +135,14 @@ export default class TMXTileMap {
|
|
|
136
135
|
/**
|
|
137
136
|
* width of the tilemap in tiles
|
|
138
137
|
* @public
|
|
139
|
-
* @type {
|
|
138
|
+
* @type {number}
|
|
140
139
|
* @name me.TMXTileMap#cols
|
|
141
140
|
*/
|
|
142
141
|
this.cols = +data.width;
|
|
143
142
|
/**
|
|
144
143
|
* height of the tilemap in tiles
|
|
145
144
|
* @public
|
|
146
|
-
* @type {
|
|
145
|
+
* @type {number}
|
|
147
146
|
* @name me.TMXTileMap#rows
|
|
148
147
|
*/
|
|
149
148
|
this.rows = +data.height;
|
|
@@ -151,7 +150,7 @@ export default class TMXTileMap {
|
|
|
151
150
|
/**
|
|
152
151
|
* Tile width
|
|
153
152
|
* @public
|
|
154
|
-
* @type {
|
|
153
|
+
* @type {number}
|
|
155
154
|
* @name me.TMXTileMap#tilewidth
|
|
156
155
|
*/
|
|
157
156
|
this.tilewidth = +data.tilewidth;
|
|
@@ -159,7 +158,7 @@ export default class TMXTileMap {
|
|
|
159
158
|
/**
|
|
160
159
|
* Tile height
|
|
161
160
|
* @public
|
|
162
|
-
* @type {
|
|
161
|
+
* @type {number}
|
|
163
162
|
* @name me.TMXTileMap#tileheight
|
|
164
163
|
*/
|
|
165
164
|
this.tileheight = +data.tileheight;
|
|
@@ -167,7 +166,7 @@ export default class TMXTileMap {
|
|
|
167
166
|
/**
|
|
168
167
|
* is the map an infinite map
|
|
169
168
|
* @public
|
|
170
|
-
* @type {
|
|
169
|
+
* @type {number}
|
|
171
170
|
* @default 0
|
|
172
171
|
* @name me.TMXTileMap#infinite
|
|
173
172
|
*/
|
|
@@ -176,17 +175,17 @@ export default class TMXTileMap {
|
|
|
176
175
|
/**
|
|
177
176
|
* the map orientation type. melonJS supports “orthogonal”, “isometric”, “staggered” and “hexagonal”.
|
|
178
177
|
* @public
|
|
179
|
-
* @type {
|
|
178
|
+
* @type {string}
|
|
180
179
|
* @default "orthogonal"
|
|
181
180
|
* @name me.TMXTileMap#orientation
|
|
182
181
|
*/
|
|
183
182
|
this.orientation = data.orientation;
|
|
184
183
|
|
|
185
184
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
* the order in which tiles on orthogonal tile layers are rendered.
|
|
186
|
+
* (valid values are "left-down", "left-up", "right-down", "right-up")
|
|
188
187
|
* @public
|
|
189
|
-
* @type {
|
|
188
|
+
* @type {string}
|
|
190
189
|
* @default "right-down"
|
|
191
190
|
* @name me.TMXTileMap#renderorder
|
|
192
191
|
*/
|
|
@@ -195,7 +194,7 @@ export default class TMXTileMap {
|
|
|
195
194
|
/**
|
|
196
195
|
* the TMX format version
|
|
197
196
|
* @public
|
|
198
|
-
* @type {
|
|
197
|
+
* @type {string}
|
|
199
198
|
* @name me.TMXTileMap#version
|
|
200
199
|
*/
|
|
201
200
|
this.version = data.version;
|
|
@@ -203,7 +202,7 @@ export default class TMXTileMap {
|
|
|
203
202
|
/**
|
|
204
203
|
* The Tiled version used to save the file (since Tiled 1.0.1).
|
|
205
204
|
* @public
|
|
206
|
-
* @type {
|
|
205
|
+
* @type {string}
|
|
207
206
|
* @name me.TMXTileMap#tiledversion
|
|
208
207
|
*/
|
|
209
208
|
this.tiledversion = data.tiledversion;
|
|
@@ -258,10 +257,10 @@ export default class TMXTileMap {
|
|
|
258
257
|
/**
|
|
259
258
|
* Return the map default renderer
|
|
260
259
|
* @name getRenderer
|
|
261
|
-
* @
|
|
260
|
+
* @memberof me.TMXTileMap
|
|
262
261
|
* @public
|
|
263
262
|
* @function
|
|
264
|
-
* @
|
|
263
|
+
* @returns {me.TMXRenderer} a TMX renderer
|
|
265
264
|
*/
|
|
266
265
|
getRenderer() {
|
|
267
266
|
if ((typeof(this.renderer) === "undefined") || (!this.renderer.canRender(this))) {
|
|
@@ -275,7 +274,7 @@ export default class TMXTileMap {
|
|
|
275
274
|
* @name me.TMXRenderer#getBounds
|
|
276
275
|
* @public
|
|
277
276
|
* @function
|
|
278
|
-
* @
|
|
277
|
+
* @returns {me.Bounds}
|
|
279
278
|
*/
|
|
280
279
|
getBounds() {
|
|
281
280
|
// calculated in the constructor
|
|
@@ -369,7 +368,7 @@ export default class TMXTileMap {
|
|
|
369
368
|
* @name me.TMXTileMap#addTo
|
|
370
369
|
* @public
|
|
371
370
|
* @function
|
|
372
|
-
* @param {me.Container} target container
|
|
371
|
+
* @param {me.Container} container target container
|
|
373
372
|
* @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
373
|
* @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
374
|
* @example
|
|
@@ -404,8 +403,10 @@ export default class TMXTileMap {
|
|
|
404
403
|
// sort everything (recursively)
|
|
405
404
|
container.sort(true);
|
|
406
405
|
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
/**
|
|
407
|
+
* callback funtion for the viewport resize event
|
|
408
|
+
* @ignore
|
|
409
|
+
*/
|
|
409
410
|
function _setBounds(width, height) {
|
|
410
411
|
// adjust the viewport bounds if level is smaller
|
|
411
412
|
viewport.setBounds(
|
|
@@ -442,7 +443,7 @@ export default class TMXTileMap {
|
|
|
442
443
|
* @function
|
|
443
444
|
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
444
445
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
445
|
-
* @
|
|
446
|
+
* @returns {me.Renderable[]} Array of Objects
|
|
446
447
|
*/
|
|
447
448
|
getObjects(flatten) {
|
|
448
449
|
var objects = [];
|
|
@@ -589,7 +590,7 @@ export default class TMXTileMap {
|
|
|
589
590
|
* @name me.TMXTileMap#getLayers
|
|
590
591
|
* @public
|
|
591
592
|
* @function
|
|
592
|
-
* @
|
|
593
|
+
* @returns {me.TMXLayer[]} Array of Layers
|
|
593
594
|
*/
|
|
594
595
|
getLayers() {
|
|
595
596
|
// parse the map for objects
|
|
@@ -8,9 +8,8 @@ import loader from "./../../loader/loader.js";
|
|
|
8
8
|
* @classdesc
|
|
9
9
|
* a TMX Tile Set Object
|
|
10
10
|
* @class TMXTileset
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @param {Object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
11
|
+
* @memberof me
|
|
12
|
+
* @param {object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
14
13
|
*/
|
|
15
14
|
export default class TMXTileset {
|
|
16
15
|
|
|
@@ -51,7 +50,7 @@ export default class TMXTileset {
|
|
|
51
50
|
/**
|
|
52
51
|
* Tileset contains animated tiles
|
|
53
52
|
* @public
|
|
54
|
-
* @type
|
|
53
|
+
* @type {boolean}
|
|
55
54
|
* @name me.TMXTileset#isAnimated
|
|
56
55
|
*/
|
|
57
56
|
this.isAnimated = false;
|
|
@@ -59,7 +58,7 @@ export default class TMXTileset {
|
|
|
59
58
|
/**
|
|
60
59
|
* true if the tileset is a "Collection of Image" Tileset
|
|
61
60
|
* @public
|
|
62
|
-
* @type
|
|
61
|
+
* @type {boolean}
|
|
63
62
|
* @name me.TMXTileset#isCollection
|
|
64
63
|
*/
|
|
65
64
|
this.isCollection = false;
|
|
@@ -67,7 +66,7 @@ export default class TMXTileset {
|
|
|
67
66
|
/**
|
|
68
67
|
* Tileset animations
|
|
69
68
|
* @private
|
|
70
|
-
* @type Map
|
|
69
|
+
* @type {Map}
|
|
71
70
|
* @name me.TMXTileset#animations
|
|
72
71
|
*/
|
|
73
72
|
this.animations = new Map();
|
|
@@ -75,7 +74,7 @@ export default class TMXTileset {
|
|
|
75
74
|
/**
|
|
76
75
|
* Remember the last update timestamp to prevent too many animation updates
|
|
77
76
|
* @private
|
|
78
|
-
* @type Map
|
|
77
|
+
* @type {Map}
|
|
79
78
|
* @name me.TMXTileset#_lastUpdate
|
|
80
79
|
*/
|
|
81
80
|
this._lastUpdate = 0;
|
|
@@ -173,8 +172,8 @@ export default class TMXTileset {
|
|
|
173
172
|
* @name me.TMXTileset#getTileImage
|
|
174
173
|
* @public
|
|
175
174
|
* @function
|
|
176
|
-
* @param {
|
|
177
|
-
* @
|
|
175
|
+
* @param {number} gid
|
|
176
|
+
* @returns {Image} corresponding image or undefined
|
|
178
177
|
*/
|
|
179
178
|
getTileImage(gid) {
|
|
180
179
|
return this.imageCollection[gid];
|
|
@@ -196,8 +195,8 @@ export default class TMXTileset {
|
|
|
196
195
|
* @name me.TMXTileset#contains
|
|
197
196
|
* @public
|
|
198
197
|
* @function
|
|
199
|
-
* @param {
|
|
200
|
-
* @
|
|
198
|
+
* @param {number} gid
|
|
199
|
+
* @returns {boolean}
|
|
201
200
|
*/
|
|
202
201
|
contains(gid) {
|
|
203
202
|
return gid >= this.firstgid && gid <= this.lastgid;
|
|
@@ -208,8 +207,8 @@ export default class TMXTileset {
|
|
|
208
207
|
* @name me.TMXTileset#getViewTileId
|
|
209
208
|
* @public
|
|
210
209
|
* @function
|
|
211
|
-
* @param {
|
|
212
|
-
* @
|
|
210
|
+
* @param {number} gid Global tile ID
|
|
211
|
+
* @returns {number} View tile ID
|
|
213
212
|
*/
|
|
214
213
|
getViewTileId(gid) {
|
|
215
214
|
var localId = gid - this.firstgid;
|
|
@@ -227,8 +226,8 @@ export default class TMXTileset {
|
|
|
227
226
|
* @name me.TMXTileset#getTileProperties
|
|
228
227
|
* @public
|
|
229
228
|
* @function
|
|
230
|
-
* @param {
|
|
231
|
-
* @
|
|
229
|
+
* @param {number} tileId
|
|
230
|
+
* @returns {object}
|
|
232
231
|
*/
|
|
233
232
|
getTileProperties(tileId) {
|
|
234
233
|
return this.TileProperties[tileId];
|
|
@@ -6,8 +6,7 @@ var TMX_CLEAR_BIT_MASK = ~(0x80000000 | 0x40000000 | 0x20000000);
|
|
|
6
6
|
* @classdesc
|
|
7
7
|
* an object containing all tileset
|
|
8
8
|
* @class TMXTilesetGroup
|
|
9
|
-
* @
|
|
10
|
-
* @constructor
|
|
9
|
+
* @memberof me
|
|
11
10
|
*/
|
|
12
11
|
export default class TMXTilesetGroup {
|
|
13
12
|
|
|
@@ -33,8 +32,8 @@ export default class TMXTilesetGroup {
|
|
|
33
32
|
* @name me.TMXTilesetGroup#getTilesetByIndex
|
|
34
33
|
* @public
|
|
35
34
|
* @function
|
|
36
|
-
* @param {
|
|
37
|
-
* @
|
|
35
|
+
* @param {number} i
|
|
36
|
+
* @returns {me.TMXTileset} corresponding tileset
|
|
38
37
|
*/
|
|
39
38
|
getTilesetByIndex(i) {
|
|
40
39
|
return this.tilesets[i];
|
|
@@ -46,8 +45,8 @@ export default class TMXTilesetGroup {
|
|
|
46
45
|
* @name me.TMXTilesetGroup#getTilesetByGid
|
|
47
46
|
* @public
|
|
48
47
|
* @function
|
|
49
|
-
* @param {
|
|
50
|
-
* @
|
|
48
|
+
* @param {number} gid
|
|
49
|
+
* @returns {me.TMXTileset} corresponding tileset
|
|
51
50
|
*/
|
|
52
51
|
getTilesetByGid(gid) {
|
|
53
52
|
var invalidRange = -1;
|