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