melonjs 10.3.0 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/melonjs.js +2419 -3072
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +3417 -3816
- package/dist/melonjs.module.js +2737 -3002
- package/package.json +16 -16
- package/src/audio/audio.js +29 -30
- package/src/camera/camera2d.js +46 -56
- package/src/entity/draggable.js +12 -13
- package/src/entity/droptarget.js +13 -15
- package/src/entity/entity.js +30 -36
- package/src/game.js +21 -22
- package/src/geometries/ellipse.js +40 -46
- package/src/geometries/line.js +9 -11
- package/src/geometries/poly.js +53 -53
- package/src/geometries/rectangle.js +42 -44
- package/src/index.js +4 -14
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +30 -31
- package/src/input/pointerevent.js +26 -26
- package/src/lang/deprecated.js +25 -6
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -8
- package/src/level/tiled/TMXLayer.js +30 -32
- package/src/level/tiled/TMXObject.js +21 -21
- package/src/level/tiled/TMXTile.js +18 -18
- package/src/level/tiled/TMXTileMap.js +37 -44
- package/src/level/tiled/TMXTileset.js +12 -15
- package/src/level/tiled/TMXTilesetGroup.js +9 -9
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
- package/src/level/tiled/renderer/TMXRenderer.js +24 -25
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
- package/src/loader/loader.js +14 -15
- package/src/loader/loadingscreen.js +2 -4
- package/src/math/color.js +47 -66
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -58
- package/src/math/matrix3.js +56 -62
- package/src/math/observable_vector2.js +75 -76
- package/src/math/observable_vector3.js +79 -80
- package/src/math/vector2.js +91 -92
- package/src/math/vector3.js +94 -96
- package/src/particles/emitter.js +38 -40
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +44 -142
- package/src/physics/bounds.js +47 -47
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +17 -19
- package/src/physics/sat.js +26 -26
- package/src/physics/world.js +24 -28
- package/src/plugin/plugin.js +11 -14
- package/src/renderable/GUI.js +41 -46
- package/src/renderable/collectable.js +4 -8
- package/src/renderable/colorlayer.js +6 -10
- package/src/renderable/container.js +87 -72
- package/src/renderable/imagelayer.js +25 -31
- package/src/renderable/nineslicesprite.js +41 -41
- package/src/renderable/renderable.js +112 -122
- package/src/renderable/sprite.js +62 -68
- package/src/renderable/trigger.js +25 -30
- package/src/state/stage.js +13 -17
- package/src/state/state.js +26 -27
- package/src/system/device.js +74 -75
- package/src/system/event.js +71 -72
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -54
- package/src/text/bitmaptextdata.js +10 -10
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +44 -49
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +43 -44
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +58 -59
- package/src/video/renderer.js +49 -53
- package/src/video/texture.js +98 -111
- package/src/video/texture_cache.js +2 -2
- package/src/video/video.js +15 -16
- package/src/video/webgl/glshader.js +37 -38
- package/src/video/webgl/webgl_compositor.js +31 -32
- package/src/video/webgl/webgl_renderer.js +79 -80
|
@@ -7,9 +7,9 @@ import Line from "./../../geometries/line.js";
|
|
|
7
7
|
import { degToRad } from "./../../math/math.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* @classdesc
|
|
10
11
|
* a TMX Object defintion, as defined in Tiled
|
|
11
12
|
* (Object definition is translated into the virtual `me.game.world` using `me.Renderable`)
|
|
12
|
-
* @class TMXObject
|
|
13
13
|
* @ignore
|
|
14
14
|
*/
|
|
15
15
|
export default class TMXObject {
|
|
@@ -21,7 +21,7 @@ export default class TMXObject {
|
|
|
21
21
|
* @public
|
|
22
22
|
* @type {object[]}
|
|
23
23
|
* @name points
|
|
24
|
-
* @memberof
|
|
24
|
+
* @memberof TMXObject
|
|
25
25
|
*/
|
|
26
26
|
this.points = undefined;
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ export default class TMXObject {
|
|
|
30
30
|
* @public
|
|
31
31
|
* @type {string}
|
|
32
32
|
* @name name
|
|
33
|
-
* @memberof
|
|
33
|
+
* @memberof TMXObject
|
|
34
34
|
*/
|
|
35
35
|
this.name = settings.name;
|
|
36
36
|
|
|
@@ -39,7 +39,7 @@ export default class TMXObject {
|
|
|
39
39
|
* @public
|
|
40
40
|
* @type {number}
|
|
41
41
|
* @name x
|
|
42
|
-
* @memberof
|
|
42
|
+
* @memberof TMXObject
|
|
43
43
|
*/
|
|
44
44
|
this.x = +settings.x;
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ export default class TMXObject {
|
|
|
48
48
|
* @public
|
|
49
49
|
* @type {number}
|
|
50
50
|
* @name y
|
|
51
|
-
* @memberof
|
|
51
|
+
* @memberof TMXObject
|
|
52
52
|
*/
|
|
53
53
|
this.y = +settings.y;
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ export default class TMXObject {
|
|
|
57
57
|
* @public
|
|
58
58
|
* @type {number}
|
|
59
59
|
* @name z
|
|
60
|
-
* @memberof
|
|
60
|
+
* @memberof TMXObject
|
|
61
61
|
*/
|
|
62
62
|
this.z = +z;
|
|
63
63
|
|
|
@@ -66,7 +66,7 @@ export default class TMXObject {
|
|
|
66
66
|
* @public
|
|
67
67
|
* @type {number}
|
|
68
68
|
* @name width
|
|
69
|
-
* @memberof
|
|
69
|
+
* @memberof TMXObject
|
|
70
70
|
*/
|
|
71
71
|
this.width = +settings.width || 0;
|
|
72
72
|
|
|
@@ -75,7 +75,7 @@ export default class TMXObject {
|
|
|
75
75
|
* @public
|
|
76
76
|
* @type {number}
|
|
77
77
|
* @name height
|
|
78
|
-
* @memberof
|
|
78
|
+
* @memberof TMXObject
|
|
79
79
|
*/
|
|
80
80
|
this.height = +settings.height || 0;
|
|
81
81
|
|
|
@@ -85,7 +85,7 @@ export default class TMXObject {
|
|
|
85
85
|
* @public
|
|
86
86
|
* @type {number}
|
|
87
87
|
* @name gid
|
|
88
|
-
* @memberof
|
|
88
|
+
* @memberof TMXObject
|
|
89
89
|
*/
|
|
90
90
|
this.gid = +settings.gid || null;
|
|
91
91
|
|
|
@@ -94,7 +94,7 @@ export default class TMXObject {
|
|
|
94
94
|
* @public
|
|
95
95
|
* @type {string}
|
|
96
96
|
* @name tintcolor
|
|
97
|
-
* @memberof
|
|
97
|
+
* @memberof TMXObject
|
|
98
98
|
*/
|
|
99
99
|
this.tintcolor = settings.tintcolor;
|
|
100
100
|
|
|
@@ -103,7 +103,7 @@ export default class TMXObject {
|
|
|
103
103
|
* @public
|
|
104
104
|
* @type {string}
|
|
105
105
|
* @name type
|
|
106
|
-
* @memberof
|
|
106
|
+
* @memberof TMXObject
|
|
107
107
|
*/
|
|
108
108
|
this.type = settings.type;
|
|
109
109
|
|
|
@@ -113,7 +113,7 @@ export default class TMXObject {
|
|
|
113
113
|
* @type {object}
|
|
114
114
|
* @see http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#text
|
|
115
115
|
* @name type
|
|
116
|
-
* @memberof
|
|
116
|
+
* @memberof TMXObject
|
|
117
117
|
*/
|
|
118
118
|
this.type = settings.type;
|
|
119
119
|
|
|
@@ -122,7 +122,7 @@ export default class TMXObject {
|
|
|
122
122
|
* @public
|
|
123
123
|
* @type {number}
|
|
124
124
|
* @name rotation
|
|
125
|
-
* @memberof
|
|
125
|
+
* @memberof TMXObject
|
|
126
126
|
*/
|
|
127
127
|
this.rotation = degToRad(+settings.rotation || 0);
|
|
128
128
|
|
|
@@ -131,7 +131,7 @@ export default class TMXObject {
|
|
|
131
131
|
* @public
|
|
132
132
|
* @type {number}
|
|
133
133
|
* @name id
|
|
134
|
-
* @memberof
|
|
134
|
+
* @memberof TMXObject
|
|
135
135
|
*/
|
|
136
136
|
this.id = +settings.id || undefined;
|
|
137
137
|
|
|
@@ -140,7 +140,7 @@ export default class TMXObject {
|
|
|
140
140
|
* @public
|
|
141
141
|
* @type {string}
|
|
142
142
|
* @name orientation
|
|
143
|
-
* @memberof
|
|
143
|
+
* @memberof TMXObject
|
|
144
144
|
*/
|
|
145
145
|
this.orientation = map.orientation;
|
|
146
146
|
|
|
@@ -149,7 +149,7 @@ export default class TMXObject {
|
|
|
149
149
|
* @public
|
|
150
150
|
* @type {object[]}
|
|
151
151
|
* @name shapes
|
|
152
|
-
* @memberof
|
|
152
|
+
* @memberof TMXObject
|
|
153
153
|
*/
|
|
154
154
|
this.shapes = undefined;
|
|
155
155
|
|
|
@@ -158,7 +158,7 @@ export default class TMXObject {
|
|
|
158
158
|
* @public
|
|
159
159
|
* @type {boolean}
|
|
160
160
|
* @name isEllipse
|
|
161
|
-
* @memberof
|
|
161
|
+
* @memberof TMXObject
|
|
162
162
|
*/
|
|
163
163
|
this.isEllipse = false;
|
|
164
164
|
|
|
@@ -167,7 +167,7 @@ export default class TMXObject {
|
|
|
167
167
|
* @public
|
|
168
168
|
* @type {boolean}
|
|
169
169
|
* @name isPolygon
|
|
170
|
-
* @memberof
|
|
170
|
+
* @memberof TMXObject
|
|
171
171
|
*/
|
|
172
172
|
this.isPolygon = false;
|
|
173
173
|
|
|
@@ -176,7 +176,7 @@ export default class TMXObject {
|
|
|
176
176
|
* @public
|
|
177
177
|
* @type {boolean}
|
|
178
178
|
* @name isPolyLine
|
|
179
|
-
* @memberof
|
|
179
|
+
* @memberof TMXObject
|
|
180
180
|
*/
|
|
181
181
|
this.isPolyLine = false;
|
|
182
182
|
|
|
@@ -248,10 +248,10 @@ export default class TMXObject {
|
|
|
248
248
|
/**
|
|
249
249
|
* parses the TMX shape definition and returns a corresponding array of me.Shape object
|
|
250
250
|
* @name parseTMXShapes
|
|
251
|
-
* @memberof
|
|
251
|
+
* @memberof TMXObject
|
|
252
252
|
* @private
|
|
253
253
|
* @function
|
|
254
|
-
* @returns {
|
|
254
|
+
* @returns {Polygon[]|Line[]|Ellipse[]} an array of shape objects
|
|
255
255
|
*/
|
|
256
256
|
parseTMXShapes() {
|
|
257
257
|
var i = 0;
|
|
@@ -9,17 +9,17 @@ var TMX_FLIP_H = 0x80000000,
|
|
|
9
9
|
TMX_CLEAR_BIT_MASK = ~(0x80000000 | 0x40000000 | 0x20000000);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
+
* @classdesc
|
|
12
13
|
* a basic tile object
|
|
13
|
-
* @
|
|
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
|
|
19
|
-
* @param {me.TMXTileset} tileset the corresponding tileset object
|
|
14
|
+
* @augments Bounds
|
|
20
15
|
*/
|
|
21
16
|
class Tile extends Bounds {
|
|
22
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @param {number} x x index of the Tile in the map
|
|
19
|
+
* @param {number} y y index of the Tile in the map
|
|
20
|
+
* @param {number} gid tile gid
|
|
21
|
+
* @param {TMXTileset} tileset the corresponding tileset object
|
|
22
|
+
*/
|
|
23
23
|
constructor(x, y, gid, tileset) {
|
|
24
24
|
var width, height;
|
|
25
25
|
|
|
@@ -41,8 +41,8 @@ class Tile extends Bounds {
|
|
|
41
41
|
/**
|
|
42
42
|
* tileset
|
|
43
43
|
* @public
|
|
44
|
-
* @type {
|
|
45
|
-
* @name
|
|
44
|
+
* @type {TMXTileset}
|
|
45
|
+
* @name Tile#tileset
|
|
46
46
|
*/
|
|
47
47
|
this.tileset = tileset;
|
|
48
48
|
|
|
@@ -60,28 +60,28 @@ class Tile extends Bounds {
|
|
|
60
60
|
* tileId
|
|
61
61
|
* @public
|
|
62
62
|
* @type {number}
|
|
63
|
-
* @name
|
|
63
|
+
* @name Tile#tileId
|
|
64
64
|
*/
|
|
65
65
|
this.tileId = gid;
|
|
66
66
|
/**
|
|
67
67
|
* True if the tile is flipped horizontally<br>
|
|
68
68
|
* @public
|
|
69
69
|
* @type {boolean}
|
|
70
|
-
* @name
|
|
70
|
+
* @name Tile#flipX
|
|
71
71
|
*/
|
|
72
72
|
this.flippedX = (this.tileId & TMX_FLIP_H) !== 0;
|
|
73
73
|
/**
|
|
74
74
|
* True if the tile is flipped vertically<br>
|
|
75
75
|
* @public
|
|
76
76
|
* @type {boolean}
|
|
77
|
-
* @name
|
|
77
|
+
* @name Tile#flippedY
|
|
78
78
|
*/
|
|
79
79
|
this.flippedY = (this.tileId & TMX_FLIP_V) !== 0;
|
|
80
80
|
/**
|
|
81
81
|
* True if the tile is flipped anti-diagonally<br>
|
|
82
82
|
* @public
|
|
83
83
|
* @type {boolean}
|
|
84
|
-
* @name
|
|
84
|
+
* @name Tile#flippedAD
|
|
85
85
|
*/
|
|
86
86
|
this.flippedAD = (this.tileId & TMX_FLIP_AD) !== 0;
|
|
87
87
|
|
|
@@ -89,7 +89,7 @@ class Tile extends Bounds {
|
|
|
89
89
|
* Global flag that indicates if the tile is flipped<br>
|
|
90
90
|
* @public
|
|
91
91
|
* @type {boolean}
|
|
92
|
-
* @name
|
|
92
|
+
* @name Tile#flipped
|
|
93
93
|
*/
|
|
94
94
|
this.flipped = this.flippedX || this.flippedY || this.flippedAD;
|
|
95
95
|
|
|
@@ -130,11 +130,11 @@ class Tile extends Bounds {
|
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* return a renderable object for this Tile object
|
|
133
|
-
* @name
|
|
133
|
+
* @name Tile#getRenderable
|
|
134
134
|
* @public
|
|
135
135
|
* @function
|
|
136
|
-
* @param {object} [settings] see {@link
|
|
137
|
-
* @returns {
|
|
136
|
+
* @param {object} [settings] see {@link Sprite}
|
|
137
|
+
* @returns {Renderable} a me.Sprite object
|
|
138
138
|
*/
|
|
139
139
|
getRenderable(settings) {
|
|
140
140
|
var renderable;
|
|
@@ -103,19 +103,17 @@ function readObjectGroup(map, data, z) {
|
|
|
103
103
|
* @classdesc
|
|
104
104
|
* a TMX Tile Map Object
|
|
105
105
|
* Tiled QT +0.7.x format
|
|
106
|
-
* @class TMXTileMap
|
|
107
|
-
* @memberof me
|
|
108
|
-
* @param {string} levelId name of TMX map
|
|
109
|
-
* @param {object} data TMX map in JSON format
|
|
110
|
-
* @example
|
|
111
|
-
* // create a new level object based on the TMX JSON object
|
|
112
|
-
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
113
|
-
* // add the level to the game world container
|
|
114
|
-
* level.addTo(me.game.world, true);
|
|
115
106
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
class TMXTileMap {
|
|
108
|
+
/**
|
|
109
|
+
* @param {string} levelId name of TMX map
|
|
110
|
+
* @param {object} data TMX map in JSON format
|
|
111
|
+
* @example
|
|
112
|
+
* // create a new level object based on the TMX JSON object
|
|
113
|
+
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
114
|
+
* // add the level to the game world container
|
|
115
|
+
* level.addTo(me.game.world, true);
|
|
116
|
+
*/
|
|
119
117
|
constructor(levelId, data) {
|
|
120
118
|
|
|
121
119
|
/**
|
|
@@ -128,7 +126,7 @@ export default class TMXTileMap {
|
|
|
128
126
|
* name of the tilemap
|
|
129
127
|
* @public
|
|
130
128
|
* @type {string}
|
|
131
|
-
* @name
|
|
129
|
+
* @name TMXTileMap#name
|
|
132
130
|
*/
|
|
133
131
|
this.name = levelId;
|
|
134
132
|
|
|
@@ -136,14 +134,14 @@ export default class TMXTileMap {
|
|
|
136
134
|
* width of the tilemap in tiles
|
|
137
135
|
* @public
|
|
138
136
|
* @type {number}
|
|
139
|
-
* @name
|
|
137
|
+
* @name TMXTileMap#cols
|
|
140
138
|
*/
|
|
141
139
|
this.cols = +data.width;
|
|
142
140
|
/**
|
|
143
141
|
* height of the tilemap in tiles
|
|
144
142
|
* @public
|
|
145
143
|
* @type {number}
|
|
146
|
-
* @name
|
|
144
|
+
* @name TMXTileMap#rows
|
|
147
145
|
*/
|
|
148
146
|
this.rows = +data.height;
|
|
149
147
|
|
|
@@ -151,7 +149,7 @@ export default class TMXTileMap {
|
|
|
151
149
|
* Tile width
|
|
152
150
|
* @public
|
|
153
151
|
* @type {number}
|
|
154
|
-
* @name
|
|
152
|
+
* @name TMXTileMap#tilewidth
|
|
155
153
|
*/
|
|
156
154
|
this.tilewidth = +data.tilewidth;
|
|
157
155
|
|
|
@@ -159,7 +157,7 @@ export default class TMXTileMap {
|
|
|
159
157
|
* Tile height
|
|
160
158
|
* @public
|
|
161
159
|
* @type {number}
|
|
162
|
-
* @name
|
|
160
|
+
* @name TMXTileMap#tileheight
|
|
163
161
|
*/
|
|
164
162
|
this.tileheight = +data.tileheight;
|
|
165
163
|
|
|
@@ -168,7 +166,7 @@ export default class TMXTileMap {
|
|
|
168
166
|
* @public
|
|
169
167
|
* @type {number}
|
|
170
168
|
* @default 0
|
|
171
|
-
* @name
|
|
169
|
+
* @name TMXTileMap#infinite
|
|
172
170
|
*/
|
|
173
171
|
this.infinite = +data.infinite;
|
|
174
172
|
|
|
@@ -177,7 +175,7 @@ export default class TMXTileMap {
|
|
|
177
175
|
* @public
|
|
178
176
|
* @type {string}
|
|
179
177
|
* @default "orthogonal"
|
|
180
|
-
* @name
|
|
178
|
+
* @name TMXTileMap#orientation
|
|
181
179
|
*/
|
|
182
180
|
this.orientation = data.orientation;
|
|
183
181
|
|
|
@@ -187,7 +185,7 @@ export default class TMXTileMap {
|
|
|
187
185
|
* @public
|
|
188
186
|
* @type {string}
|
|
189
187
|
* @default "right-down"
|
|
190
|
-
* @name
|
|
188
|
+
* @name TMXTileMap#renderorder
|
|
191
189
|
*/
|
|
192
190
|
this.renderorder = data.renderorder || "right-down";
|
|
193
191
|
|
|
@@ -195,7 +193,7 @@ export default class TMXTileMap {
|
|
|
195
193
|
* the TMX format version
|
|
196
194
|
* @public
|
|
197
195
|
* @type {string}
|
|
198
|
-
* @name
|
|
196
|
+
* @name TMXTileMap#version
|
|
199
197
|
*/
|
|
200
198
|
this.version = data.version;
|
|
201
199
|
|
|
@@ -203,7 +201,7 @@ export default class TMXTileMap {
|
|
|
203
201
|
* The Tiled version used to save the file (since Tiled 1.0.1).
|
|
204
202
|
* @public
|
|
205
203
|
* @type {string}
|
|
206
|
-
* @name
|
|
204
|
+
* @name TMXTileMap#tiledversion
|
|
207
205
|
*/
|
|
208
206
|
this.tiledversion = data.tiledversion;
|
|
209
207
|
|
|
@@ -257,10 +255,10 @@ export default class TMXTileMap {
|
|
|
257
255
|
/**
|
|
258
256
|
* Return the map default renderer
|
|
259
257
|
* @name getRenderer
|
|
260
|
-
* @memberof
|
|
258
|
+
* @memberof TMXTileMap
|
|
261
259
|
* @public
|
|
262
260
|
* @function
|
|
263
|
-
* @returns {
|
|
261
|
+
* @returns {TMXRenderer} a TMX renderer
|
|
264
262
|
*/
|
|
265
263
|
getRenderer() {
|
|
266
264
|
if ((typeof(this.renderer) === "undefined") || (!this.renderer.canRender(this))) {
|
|
@@ -271,10 +269,10 @@ export default class TMXTileMap {
|
|
|
271
269
|
|
|
272
270
|
/**
|
|
273
271
|
* return the map bounding rect
|
|
274
|
-
* @name
|
|
272
|
+
* @name TMXRenderer#getBounds
|
|
275
273
|
* @public
|
|
276
274
|
* @function
|
|
277
|
-
* @returns {
|
|
275
|
+
* @returns {Bounds}
|
|
278
276
|
*/
|
|
279
277
|
getBounds() {
|
|
280
278
|
// calculated in the constructor
|
|
@@ -309,17 +307,6 @@ export default class TMXTileMap {
|
|
|
309
307
|
});
|
|
310
308
|
}
|
|
311
309
|
|
|
312
|
-
// check if a user-defined background color is defined
|
|
313
|
-
if (this.backgroundcolor) {
|
|
314
|
-
this.layers.push(
|
|
315
|
-
pool.pull("ColorLayer",
|
|
316
|
-
"background_color",
|
|
317
|
-
this.backgroundcolor,
|
|
318
|
-
zOrder++
|
|
319
|
-
)
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
310
|
// check if a background image is defined
|
|
324
311
|
if (this.background_image) {
|
|
325
312
|
// add a new image layer
|
|
@@ -365,10 +352,10 @@ export default class TMXTileMap {
|
|
|
365
352
|
/**
|
|
366
353
|
* add all the map layers and objects to the given container.
|
|
367
354
|
* note : this will not automatically update the camera viewport
|
|
368
|
-
* @name
|
|
355
|
+
* @name TMXTileMap#addTo
|
|
369
356
|
* @public
|
|
370
357
|
* @function
|
|
371
|
-
* @param {
|
|
358
|
+
* @param {Container} container target container
|
|
372
359
|
* @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
|
|
373
360
|
* @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.
|
|
374
361
|
* @example
|
|
@@ -387,6 +374,10 @@ export default class TMXTileMap {
|
|
|
387
374
|
container.autoSort = false;
|
|
388
375
|
container.autoDepth = false;
|
|
389
376
|
|
|
377
|
+
if (this.backgroundcolor) {
|
|
378
|
+
container.backgroundColor.parseCSS(this.backgroundcolor);
|
|
379
|
+
}
|
|
380
|
+
|
|
390
381
|
// add all layers instances
|
|
391
382
|
this.getLayers().forEach(function (layer) {
|
|
392
383
|
container.addChild(layer);
|
|
@@ -438,12 +429,12 @@ export default class TMXTileMap {
|
|
|
438
429
|
|
|
439
430
|
/**
|
|
440
431
|
* return an Array of instantiated objects, based on the map object definition
|
|
441
|
-
* @name
|
|
432
|
+
* @name TMXTileMap#getObjects
|
|
442
433
|
* @public
|
|
443
434
|
* @function
|
|
444
435
|
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
445
436
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
446
|
-
* @returns {
|
|
437
|
+
* @returns {Renderable[]} Array of Objects
|
|
447
438
|
*/
|
|
448
439
|
getObjects(flatten) {
|
|
449
440
|
var objects = [];
|
|
@@ -587,10 +578,10 @@ export default class TMXTileMap {
|
|
|
587
578
|
|
|
588
579
|
/**
|
|
589
580
|
* return all the existing layers
|
|
590
|
-
* @name
|
|
581
|
+
* @name TMXTileMap#getLayers
|
|
591
582
|
* @public
|
|
592
583
|
* @function
|
|
593
|
-
* @returns {
|
|
584
|
+
* @returns {TMXLayer[]} Array of Layers
|
|
594
585
|
*/
|
|
595
586
|
getLayers() {
|
|
596
587
|
// parse the map for objects
|
|
@@ -600,7 +591,7 @@ export default class TMXTileMap {
|
|
|
600
591
|
|
|
601
592
|
/**
|
|
602
593
|
* destroy function, clean all allocated objects
|
|
603
|
-
* @name
|
|
594
|
+
* @name TMXTileMap#destroy
|
|
604
595
|
* @public
|
|
605
596
|
* @function
|
|
606
597
|
*/
|
|
@@ -611,3 +602,5 @@ export default class TMXTileMap {
|
|
|
611
602
|
this.initialized = false;
|
|
612
603
|
}
|
|
613
604
|
};
|
|
605
|
+
|
|
606
|
+
export default TMXTileMap;
|
|
@@ -7,12 +7,11 @@ import loader from "./../../loader/loader.js";
|
|
|
7
7
|
/**
|
|
8
8
|
* @classdesc
|
|
9
9
|
* a TMX Tile Set Object
|
|
10
|
-
* @class TMXTileset
|
|
11
|
-
* @memberof me
|
|
12
|
-
* @param {object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
class TMXTileset {
|
|
12
|
+
/**
|
|
13
|
+
* @param {object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
14
|
+
*/
|
|
16
15
|
constructor(tileset) {
|
|
17
16
|
var i = 0;
|
|
18
17
|
// first gid
|
|
@@ -51,7 +50,7 @@ export default class TMXTileset {
|
|
|
51
50
|
* Tileset contains animated tiles
|
|
52
51
|
* @public
|
|
53
52
|
* @type {boolean}
|
|
54
|
-
* @name
|
|
53
|
+
* @name TMXTileset#isAnimated
|
|
55
54
|
*/
|
|
56
55
|
this.isAnimated = false;
|
|
57
56
|
|
|
@@ -59,23 +58,19 @@ export default class TMXTileset {
|
|
|
59
58
|
* true if the tileset is a "Collection of Image" Tileset
|
|
60
59
|
* @public
|
|
61
60
|
* @type {boolean}
|
|
62
|
-
* @name
|
|
61
|
+
* @name TMXTileset#isCollection
|
|
63
62
|
*/
|
|
64
63
|
this.isCollection = false;
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
66
|
* Tileset animations
|
|
68
67
|
* @private
|
|
69
|
-
* @type {Map}
|
|
70
|
-
* @name me.TMXTileset#animations
|
|
71
68
|
*/
|
|
72
69
|
this.animations = new Map();
|
|
73
70
|
|
|
74
71
|
/**
|
|
75
72
|
* Remember the last update timestamp to prevent too many animation updates
|
|
76
73
|
* @private
|
|
77
|
-
* @type {Map}
|
|
78
|
-
* @name me.TMXTileset#_lastUpdate
|
|
79
74
|
*/
|
|
80
75
|
this._lastUpdate = 0;
|
|
81
76
|
|
|
@@ -169,7 +164,7 @@ export default class TMXTileset {
|
|
|
169
164
|
|
|
170
165
|
/**
|
|
171
166
|
* return the tile image from a "Collection of Image" tileset
|
|
172
|
-
* @name
|
|
167
|
+
* @name TMXTileset#getTileImage
|
|
173
168
|
* @public
|
|
174
169
|
* @function
|
|
175
170
|
* @param {number} gid
|
|
@@ -192,7 +187,7 @@ export default class TMXTileset {
|
|
|
192
187
|
|
|
193
188
|
/**
|
|
194
189
|
* return true if the gid belongs to the tileset
|
|
195
|
-
* @name
|
|
190
|
+
* @name TMXTileset#contains
|
|
196
191
|
* @public
|
|
197
192
|
* @function
|
|
198
193
|
* @param {number} gid
|
|
@@ -204,7 +199,7 @@ export default class TMXTileset {
|
|
|
204
199
|
|
|
205
200
|
/**
|
|
206
201
|
* Get the view (local) tile ID from a GID, with animations applied
|
|
207
|
-
* @name
|
|
202
|
+
* @name TMXTileset#getViewTileId
|
|
208
203
|
* @public
|
|
209
204
|
* @function
|
|
210
205
|
* @param {number} gid Global tile ID
|
|
@@ -223,7 +218,7 @@ export default class TMXTileset {
|
|
|
223
218
|
|
|
224
219
|
/**
|
|
225
220
|
* return the properties of the specified tile
|
|
226
|
-
* @name
|
|
221
|
+
* @name TMXTileset#getTileProperties
|
|
227
222
|
* @public
|
|
228
223
|
* @function
|
|
229
224
|
* @param {number} tileId
|
|
@@ -300,3 +295,5 @@ export default class TMXTileset {
|
|
|
300
295
|
}
|
|
301
296
|
}
|
|
302
297
|
};
|
|
298
|
+
|
|
299
|
+
export default TMXTileset;
|
|
@@ -5,10 +5,8 @@ var TMX_CLEAR_BIT_MASK = ~(0x80000000 | 0x40000000 | 0x20000000);
|
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc
|
|
7
7
|
* an object containing all tileset
|
|
8
|
-
* @class TMXTilesetGroup
|
|
9
|
-
* @memberof me
|
|
10
8
|
*/
|
|
11
|
-
|
|
9
|
+
class TMXTilesetGroup {
|
|
12
10
|
|
|
13
11
|
constructor() {
|
|
14
12
|
this.tilesets = [];
|
|
@@ -17,10 +15,10 @@ export default class TMXTilesetGroup {
|
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* add a tileset to the tileset group
|
|
20
|
-
* @name
|
|
18
|
+
* @name TMXTilesetGroup#add
|
|
21
19
|
* @public
|
|
22
20
|
* @function
|
|
23
|
-
* @param
|
|
21
|
+
* @param {TMXTileset} tileset
|
|
24
22
|
*/
|
|
25
23
|
add(tileset) {
|
|
26
24
|
this.tilesets.push(tileset);
|
|
@@ -29,11 +27,11 @@ export default class TMXTilesetGroup {
|
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
29
|
* return the tileset at the specified index
|
|
32
|
-
* @name
|
|
30
|
+
* @name TMXTilesetGroup#getTilesetByIndex
|
|
33
31
|
* @public
|
|
34
32
|
* @function
|
|
35
33
|
* @param {number} i
|
|
36
|
-
* @returns {
|
|
34
|
+
* @returns {TMXTileset} corresponding tileset
|
|
37
35
|
*/
|
|
38
36
|
getTilesetByIndex(i) {
|
|
39
37
|
return this.tilesets[i];
|
|
@@ -42,11 +40,11 @@ export default class TMXTilesetGroup {
|
|
|
42
40
|
/**
|
|
43
41
|
* return the tileset corresponding to the specified id <br>
|
|
44
42
|
* will throw an exception if no matching tileset is found
|
|
45
|
-
* @name
|
|
43
|
+
* @name TMXTilesetGroup#getTilesetByGid
|
|
46
44
|
* @public
|
|
47
45
|
* @function
|
|
48
46
|
* @param {number} gid
|
|
49
|
-
* @returns {
|
|
47
|
+
* @returns {TMXTileset} corresponding tileset
|
|
50
48
|
*/
|
|
51
49
|
getTilesetByGid(gid) {
|
|
52
50
|
var invalidRange = -1;
|
|
@@ -76,3 +74,5 @@ export default class TMXTilesetGroup {
|
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
};
|
|
77
|
+
|
|
78
|
+
export default TMXTilesetGroup;
|
|
@@ -22,13 +22,12 @@ var offsetsStaggerY = [
|
|
|
22
22
|
/**
|
|
23
23
|
* @classdesc
|
|
24
24
|
* an Hexagonal Map Renderder
|
|
25
|
-
* @
|
|
26
|
-
* @memberof me
|
|
27
|
-
* @augments me.TMXRenderer
|
|
28
|
-
* @param {me.TMXTileMap} map the TMX map
|
|
25
|
+
* @augments TMXRenderer
|
|
29
26
|
*/
|
|
30
27
|
class TMXHexagonalRenderer extends TMXRenderer {
|
|
31
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @param {TMXTileMap} map the TMX map
|
|
30
|
+
*/
|
|
32
31
|
constructor(map) {
|
|
33
32
|
super(
|
|
34
33
|
map.cols,
|
|
@@ -80,11 +79,11 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* return the bounding rect for this map renderer
|
|
83
|
-
* @name
|
|
82
|
+
* @name TMXHexagonalRenderer#getBounds
|
|
84
83
|
* @public
|
|
85
84
|
* @function
|
|
86
|
-
* @param {
|
|
87
|
-
* @returns {
|
|
85
|
+
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
86
|
+
* @returns {Bounds}
|
|
88
87
|
*/
|
|
89
88
|
getBounds(layer) {
|
|
90
89
|
var bounds = layer instanceof TMXLayer ? pool.pull("Bounds") : this.bounds;
|