melonjs 10.2.1 → 10.2.2
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 +2735 -2760
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2186 -2162
- package/dist/melonjs.module.js +2323 -2362
- package/package.json +8 -9
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +2 -2
- package/src/index.js +11 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +18 -26
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +29 -25
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +44 -44
- package/src/physics/bounds.js +34 -34
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -10
- package/src/physics/quadtree.js +19 -17
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +13 -13
- package/src/renderable/renderable.js +68 -66
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +6 -6
- package/src/state/state.js +54 -54
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +39 -41
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +74 -75
- package/src/video/video.js +30 -30
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +33 -34
- package/src/video/webgl/webgl_renderer.js +104 -104
|
@@ -14,9 +14,9 @@ var TMX_FLIP_H = 0x80000000,
|
|
|
14
14
|
* @extends me.Bounds
|
|
15
15
|
* @memberOf me
|
|
16
16
|
* @constructor
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
17
|
+
* @param {number} x x index of the Tile in the map
|
|
18
|
+
* @param {number} y y index of the Tile in the map
|
|
19
|
+
* @param {number} gid tile gid
|
|
20
20
|
* @param {me.TMXTileset} tileset the corresponding tileset object
|
|
21
21
|
*/
|
|
22
22
|
class Tile extends Bounds {
|
|
@@ -42,7 +42,7 @@ class Tile extends Bounds {
|
|
|
42
42
|
/**
|
|
43
43
|
* tileset
|
|
44
44
|
* @public
|
|
45
|
-
* @type me.TMXTileset
|
|
45
|
+
* @type {me.TMXTileset}
|
|
46
46
|
* @name me.Tile#tileset
|
|
47
47
|
*/
|
|
48
48
|
this.tileset = tileset;
|
|
@@ -60,28 +60,28 @@ class Tile extends Bounds {
|
|
|
60
60
|
/**
|
|
61
61
|
* tileId
|
|
62
62
|
* @public
|
|
63
|
-
* @type
|
|
63
|
+
* @type {number}
|
|
64
64
|
* @name me.Tile#tileId
|
|
65
65
|
*/
|
|
66
66
|
this.tileId = gid;
|
|
67
67
|
/**
|
|
68
68
|
* True if the tile is flipped horizontally<br>
|
|
69
69
|
* @public
|
|
70
|
-
* @type
|
|
70
|
+
* @type {boolean}
|
|
71
71
|
* @name me.Tile#flipX
|
|
72
72
|
*/
|
|
73
73
|
this.flippedX = (this.tileId & TMX_FLIP_H) !== 0;
|
|
74
74
|
/**
|
|
75
75
|
* True if the tile is flipped vertically<br>
|
|
76
76
|
* @public
|
|
77
|
-
* @type
|
|
77
|
+
* @type {boolean}
|
|
78
78
|
* @name me.Tile#flippedY
|
|
79
79
|
*/
|
|
80
80
|
this.flippedY = (this.tileId & TMX_FLIP_V) !== 0;
|
|
81
81
|
/**
|
|
82
82
|
* True if the tile is flipped anti-diagonally<br>
|
|
83
83
|
* @public
|
|
84
|
-
* @type
|
|
84
|
+
* @type {boolean}
|
|
85
85
|
* @name me.Tile#flippedAD
|
|
86
86
|
*/
|
|
87
87
|
this.flippedAD = (this.tileId & TMX_FLIP_AD) !== 0;
|
|
@@ -89,7 +89,7 @@ class Tile extends Bounds {
|
|
|
89
89
|
/**
|
|
90
90
|
* Global flag that indicates if the tile is flipped<br>
|
|
91
91
|
* @public
|
|
92
|
-
* @type
|
|
92
|
+
* @type {boolean}
|
|
93
93
|
* @name me.Tile#flipped
|
|
94
94
|
*/
|
|
95
95
|
this.flipped = this.flippedX || this.flippedY || this.flippedAD;
|
|
@@ -108,7 +108,6 @@ class Tile extends Bounds {
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* set the transformation matrix for this tile
|
|
111
|
-
* @return {me.Matrix2d) a transformation matrix
|
|
112
111
|
* @ignore
|
|
113
112
|
*/
|
|
114
113
|
setTileTransform(transform) {
|
|
@@ -135,8 +134,8 @@ class Tile extends Bounds {
|
|
|
135
134
|
* @name me.Tile#getRenderable
|
|
136
135
|
* @public
|
|
137
136
|
* @function
|
|
138
|
-
* @param {
|
|
139
|
-
* @
|
|
137
|
+
* @param {object} [settings] see {@link me.Sprite}
|
|
138
|
+
* @returns {me.Renderable} a me.Sprite object
|
|
140
139
|
*/
|
|
141
140
|
getRenderable(settings) {
|
|
142
141
|
var renderable;
|
|
@@ -106,8 +106,8 @@ function readObjectGroup(map, data, z) {
|
|
|
106
106
|
* @class TMXTileMap
|
|
107
107
|
* @memberOf me
|
|
108
108
|
* @constructor
|
|
109
|
-
* @param {
|
|
110
|
-
* @param {
|
|
109
|
+
* @param {string} levelId name of TMX map
|
|
110
|
+
* @param {object} data TMX map in JSON format
|
|
111
111
|
* @example
|
|
112
112
|
* // create a new level object based on the TMX JSON object
|
|
113
113
|
* var level = new me.TMXTileMap(levelId, me.loader.getTMX(levelId));
|
|
@@ -128,7 +128,7 @@ export default class TMXTileMap {
|
|
|
128
128
|
/**
|
|
129
129
|
* name of the tilemap
|
|
130
130
|
* @public
|
|
131
|
-
* @type {
|
|
131
|
+
* @type {string}
|
|
132
132
|
* @name me.TMXTileMap#name
|
|
133
133
|
*/
|
|
134
134
|
this.name = levelId;
|
|
@@ -136,14 +136,14 @@ export default class TMXTileMap {
|
|
|
136
136
|
/**
|
|
137
137
|
* width of the tilemap in tiles
|
|
138
138
|
* @public
|
|
139
|
-
* @type {
|
|
139
|
+
* @type {number}
|
|
140
140
|
* @name me.TMXTileMap#cols
|
|
141
141
|
*/
|
|
142
142
|
this.cols = +data.width;
|
|
143
143
|
/**
|
|
144
144
|
* height of the tilemap in tiles
|
|
145
145
|
* @public
|
|
146
|
-
* @type {
|
|
146
|
+
* @type {number}
|
|
147
147
|
* @name me.TMXTileMap#rows
|
|
148
148
|
*/
|
|
149
149
|
this.rows = +data.height;
|
|
@@ -151,7 +151,7 @@ export default class TMXTileMap {
|
|
|
151
151
|
/**
|
|
152
152
|
* Tile width
|
|
153
153
|
* @public
|
|
154
|
-
* @type {
|
|
154
|
+
* @type {number}
|
|
155
155
|
* @name me.TMXTileMap#tilewidth
|
|
156
156
|
*/
|
|
157
157
|
this.tilewidth = +data.tilewidth;
|
|
@@ -159,7 +159,7 @@ export default class TMXTileMap {
|
|
|
159
159
|
/**
|
|
160
160
|
* Tile height
|
|
161
161
|
* @public
|
|
162
|
-
* @type {
|
|
162
|
+
* @type {number}
|
|
163
163
|
* @name me.TMXTileMap#tileheight
|
|
164
164
|
*/
|
|
165
165
|
this.tileheight = +data.tileheight;
|
|
@@ -167,7 +167,7 @@ export default class TMXTileMap {
|
|
|
167
167
|
/**
|
|
168
168
|
* is the map an infinite map
|
|
169
169
|
* @public
|
|
170
|
-
* @type {
|
|
170
|
+
* @type {number}
|
|
171
171
|
* @default 0
|
|
172
172
|
* @name me.TMXTileMap#infinite
|
|
173
173
|
*/
|
|
@@ -176,17 +176,17 @@ export default class TMXTileMap {
|
|
|
176
176
|
/**
|
|
177
177
|
* the map orientation type. melonJS supports “orthogonal”, “isometric”, “staggered” and “hexagonal”.
|
|
178
178
|
* @public
|
|
179
|
-
* @type {
|
|
179
|
+
* @type {string}
|
|
180
180
|
* @default "orthogonal"
|
|
181
181
|
* @name me.TMXTileMap#orientation
|
|
182
182
|
*/
|
|
183
183
|
this.orientation = data.orientation;
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
* the order in which tiles on orthogonal tile layers are rendered.
|
|
187
|
+
* (valid values are "left-down", "left-up", "right-down", "right-up")
|
|
188
188
|
* @public
|
|
189
|
-
* @type {
|
|
189
|
+
* @type {string}
|
|
190
190
|
* @default "right-down"
|
|
191
191
|
* @name me.TMXTileMap#renderorder
|
|
192
192
|
*/
|
|
@@ -195,7 +195,7 @@ export default class TMXTileMap {
|
|
|
195
195
|
/**
|
|
196
196
|
* the TMX format version
|
|
197
197
|
* @public
|
|
198
|
-
* @type {
|
|
198
|
+
* @type {string}
|
|
199
199
|
* @name me.TMXTileMap#version
|
|
200
200
|
*/
|
|
201
201
|
this.version = data.version;
|
|
@@ -203,7 +203,7 @@ export default class TMXTileMap {
|
|
|
203
203
|
/**
|
|
204
204
|
* The Tiled version used to save the file (since Tiled 1.0.1).
|
|
205
205
|
* @public
|
|
206
|
-
* @type {
|
|
206
|
+
* @type {string}
|
|
207
207
|
* @name me.TMXTileMap#tiledversion
|
|
208
208
|
*/
|
|
209
209
|
this.tiledversion = data.tiledversion;
|
|
@@ -261,7 +261,7 @@ export default class TMXTileMap {
|
|
|
261
261
|
* @memberOf me.TMXTileMap
|
|
262
262
|
* @public
|
|
263
263
|
* @function
|
|
264
|
-
* @
|
|
264
|
+
* @returns {me.TMXRenderer} a TMX renderer
|
|
265
265
|
*/
|
|
266
266
|
getRenderer() {
|
|
267
267
|
if ((typeof(this.renderer) === "undefined") || (!this.renderer.canRender(this))) {
|
|
@@ -275,7 +275,7 @@ export default class TMXTileMap {
|
|
|
275
275
|
* @name me.TMXRenderer#getBounds
|
|
276
276
|
* @public
|
|
277
277
|
* @function
|
|
278
|
-
* @
|
|
278
|
+
* @returns {me.Bounds}
|
|
279
279
|
*/
|
|
280
280
|
getBounds() {
|
|
281
281
|
// calculated in the constructor
|
|
@@ -369,7 +369,7 @@ export default class TMXTileMap {
|
|
|
369
369
|
* @name me.TMXTileMap#addTo
|
|
370
370
|
* @public
|
|
371
371
|
* @function
|
|
372
|
-
* @param {me.Container} target container
|
|
372
|
+
* @param {me.Container} container target container
|
|
373
373
|
* @param {boolean} [flatten=true] if true, flatten all objects into the given container, else a `me.Container` object will be created for each corresponding groups
|
|
374
374
|
* @param {boolean} [setViewportBounds=false] if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
375
375
|
* @example
|
|
@@ -404,8 +404,10 @@ export default class TMXTileMap {
|
|
|
404
404
|
// sort everything (recursively)
|
|
405
405
|
container.sort(true);
|
|
406
406
|
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
/**
|
|
408
|
+
* callback funtion for the viewport resize event
|
|
409
|
+
* @ignore
|
|
410
|
+
*/
|
|
409
411
|
function _setBounds(width, height) {
|
|
410
412
|
// adjust the viewport bounds if level is smaller
|
|
411
413
|
viewport.setBounds(
|
|
@@ -442,7 +444,7 @@ export default class TMXTileMap {
|
|
|
442
444
|
* @function
|
|
443
445
|
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
444
446
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
445
|
-
* @
|
|
447
|
+
* @returns {me.Renderable[]} Array of Objects
|
|
446
448
|
*/
|
|
447
449
|
getObjects(flatten) {
|
|
448
450
|
var objects = [];
|
|
@@ -589,7 +591,7 @@ export default class TMXTileMap {
|
|
|
589
591
|
* @name me.TMXTileMap#getLayers
|
|
590
592
|
* @public
|
|
591
593
|
* @function
|
|
592
|
-
* @
|
|
594
|
+
* @returns {me.TMXLayer[]} Array of Layers
|
|
593
595
|
*/
|
|
594
596
|
getLayers() {
|
|
595
597
|
// parse the map for objects
|
|
@@ -10,7 +10,7 @@ import loader from "./../../loader/loader.js";
|
|
|
10
10
|
* @class TMXTileset
|
|
11
11
|
* @memberOf me
|
|
12
12
|
* @constructor
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {object} tileset tileset data in JSON format ({@link http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#tileset})
|
|
14
14
|
*/
|
|
15
15
|
export default class TMXTileset {
|
|
16
16
|
|
|
@@ -51,7 +51,7 @@ export default class TMXTileset {
|
|
|
51
51
|
/**
|
|
52
52
|
* Tileset contains animated tiles
|
|
53
53
|
* @public
|
|
54
|
-
* @type
|
|
54
|
+
* @type {boolean}
|
|
55
55
|
* @name me.TMXTileset#isAnimated
|
|
56
56
|
*/
|
|
57
57
|
this.isAnimated = false;
|
|
@@ -59,7 +59,7 @@ export default class TMXTileset {
|
|
|
59
59
|
/**
|
|
60
60
|
* true if the tileset is a "Collection of Image" Tileset
|
|
61
61
|
* @public
|
|
62
|
-
* @type
|
|
62
|
+
* @type {boolean}
|
|
63
63
|
* @name me.TMXTileset#isCollection
|
|
64
64
|
*/
|
|
65
65
|
this.isCollection = false;
|
|
@@ -67,7 +67,7 @@ export default class TMXTileset {
|
|
|
67
67
|
/**
|
|
68
68
|
* Tileset animations
|
|
69
69
|
* @private
|
|
70
|
-
* @type Map
|
|
70
|
+
* @type {Map}
|
|
71
71
|
* @name me.TMXTileset#animations
|
|
72
72
|
*/
|
|
73
73
|
this.animations = new Map();
|
|
@@ -75,7 +75,7 @@ export default class TMXTileset {
|
|
|
75
75
|
/**
|
|
76
76
|
* Remember the last update timestamp to prevent too many animation updates
|
|
77
77
|
* @private
|
|
78
|
-
* @type Map
|
|
78
|
+
* @type {Map}
|
|
79
79
|
* @name me.TMXTileset#_lastUpdate
|
|
80
80
|
*/
|
|
81
81
|
this._lastUpdate = 0;
|
|
@@ -173,8 +173,8 @@ export default class TMXTileset {
|
|
|
173
173
|
* @name me.TMXTileset#getTileImage
|
|
174
174
|
* @public
|
|
175
175
|
* @function
|
|
176
|
-
* @param {
|
|
177
|
-
* @
|
|
176
|
+
* @param {number} gid
|
|
177
|
+
* @returns {Image} corresponding image or undefined
|
|
178
178
|
*/
|
|
179
179
|
getTileImage(gid) {
|
|
180
180
|
return this.imageCollection[gid];
|
|
@@ -196,8 +196,8 @@ export default class TMXTileset {
|
|
|
196
196
|
* @name me.TMXTileset#contains
|
|
197
197
|
* @public
|
|
198
198
|
* @function
|
|
199
|
-
* @param {
|
|
200
|
-
* @
|
|
199
|
+
* @param {number} gid
|
|
200
|
+
* @returns {boolean}
|
|
201
201
|
*/
|
|
202
202
|
contains(gid) {
|
|
203
203
|
return gid >= this.firstgid && gid <= this.lastgid;
|
|
@@ -208,8 +208,8 @@ export default class TMXTileset {
|
|
|
208
208
|
* @name me.TMXTileset#getViewTileId
|
|
209
209
|
* @public
|
|
210
210
|
* @function
|
|
211
|
-
* @param {
|
|
212
|
-
* @
|
|
211
|
+
* @param {number} gid Global tile ID
|
|
212
|
+
* @returns {number} View tile ID
|
|
213
213
|
*/
|
|
214
214
|
getViewTileId(gid) {
|
|
215
215
|
var localId = gid - this.firstgid;
|
|
@@ -227,8 +227,8 @@ export default class TMXTileset {
|
|
|
227
227
|
* @name me.TMXTileset#getTileProperties
|
|
228
228
|
* @public
|
|
229
229
|
* @function
|
|
230
|
-
* @param {
|
|
231
|
-
* @
|
|
230
|
+
* @param {number} tileId
|
|
231
|
+
* @returns {object}
|
|
232
232
|
*/
|
|
233
233
|
getTileProperties(tileId) {
|
|
234
234
|
return this.TileProperties[tileId];
|
|
@@ -33,8 +33,8 @@ export default class TMXTilesetGroup {
|
|
|
33
33
|
* @name me.TMXTilesetGroup#getTilesetByIndex
|
|
34
34
|
* @public
|
|
35
35
|
* @function
|
|
36
|
-
* @param {
|
|
37
|
-
* @
|
|
36
|
+
* @param {number} i
|
|
37
|
+
* @returns {me.TMXTileset} corresponding tileset
|
|
38
38
|
*/
|
|
39
39
|
getTilesetByIndex(i) {
|
|
40
40
|
return this.tilesets[i];
|
|
@@ -46,8 +46,8 @@ export default class TMXTilesetGroup {
|
|
|
46
46
|
* @name me.TMXTilesetGroup#getTilesetByGid
|
|
47
47
|
* @public
|
|
48
48
|
* @function
|
|
49
|
-
* @param {
|
|
50
|
-
* @
|
|
49
|
+
* @param {number} gid
|
|
50
|
+
* @returns {me.TMXTileset} corresponding tileset
|
|
51
51
|
*/
|
|
52
52
|
getTilesetByGid(gid) {
|
|
53
53
|
var invalidRange = -1;
|
|
@@ -76,6 +76,9 @@ function setTMXValue(name, type, value) {
|
|
|
76
76
|
return value;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* @ignore
|
|
81
|
+
*/
|
|
79
82
|
function parseAttributes(obj, elt) {
|
|
80
83
|
// do attributes
|
|
81
84
|
if (elt.attributes && elt.attributes.length > 0) {
|
|
@@ -97,9 +100,8 @@ function parseAttributes(obj, elt) {
|
|
|
97
100
|
* @ignore
|
|
98
101
|
* @function
|
|
99
102
|
* @name decompress
|
|
100
|
-
* @param {
|
|
101
|
-
* @param {
|
|
102
|
-
* @return {Number[]} Decompressed data
|
|
103
|
+
* @param {number[]} data Array of bytes
|
|
104
|
+
* @param {string} format compressed data format ("gzip","zlib")
|
|
103
105
|
*/
|
|
104
106
|
export function decompress() {
|
|
105
107
|
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
@@ -110,8 +112,8 @@ export function decompress() {
|
|
|
110
112
|
* @ignore
|
|
111
113
|
* @function
|
|
112
114
|
* @name decodeCSV
|
|
113
|
-
* @param {
|
|
114
|
-
* @
|
|
115
|
+
* @param {string} input CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
116
|
+
* @returns {number[]} Decoded data
|
|
115
117
|
*/
|
|
116
118
|
export function decodeCSV(input) {
|
|
117
119
|
var entries = input.replace("\n", "").trim().split(",");
|
|
@@ -128,9 +130,9 @@ export function decodeCSV(input) {
|
|
|
128
130
|
* @ignore
|
|
129
131
|
* @function
|
|
130
132
|
* @name decodeBase64AsArray
|
|
131
|
-
* @param {
|
|
132
|
-
* @param {
|
|
133
|
-
* @
|
|
133
|
+
* @param {string} input Base64 encoded data
|
|
134
|
+
* @param {number} [bytes] number of bytes per array entry
|
|
135
|
+
* @returns {Uint32Array} Decoded data
|
|
134
136
|
*/
|
|
135
137
|
export function decodeBase64AsArray(input, bytes) {
|
|
136
138
|
bytes = bytes || 1;
|
|
@@ -149,9 +151,9 @@ export function decodeBase64AsArray(input, bytes) {
|
|
|
149
151
|
};
|
|
150
152
|
|
|
151
153
|
/**
|
|
152
|
-
* Decode the given data
|
|
153
|
-
* @ignore
|
|
154
|
-
*/
|
|
154
|
+
* Decode the given data
|
|
155
|
+
* @ignore
|
|
156
|
+
*/
|
|
155
157
|
export function decode(data, encoding, compression) {
|
|
156
158
|
compression = compression || "none";
|
|
157
159
|
encoding = encoding || "none";
|
|
@@ -85,7 +85,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
85
85
|
* @public
|
|
86
86
|
* @function
|
|
87
87
|
* @param {me.TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
88
|
-
* @
|
|
88
|
+
* @returns {me.Bounds}
|
|
89
89
|
*/
|
|
90
90
|
getBounds(layer) {
|
|
91
91
|
var bounds = layer instanceof TMXLayer ? pool.pull("Bounds") : this.bounds;
|
|
@@ -45,7 +45,7 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
45
45
|
* @public
|
|
46
46
|
* @function
|
|
47
47
|
* @param {me.TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
48
|
-
* @
|
|
48
|
+
* @returns {me.Bounds}
|
|
49
49
|
*/
|
|
50
50
|
getBounds(layer) {
|
|
51
51
|
var bounds = layer instanceof TMXLayer ? pool.pull("Bounds") : this.bounds;
|
|
@@ -10,10 +10,10 @@ import Bounds from "./../../../physics/Bounds.js";
|
|
|
10
10
|
* @class TMXRenderer
|
|
11
11
|
* @memberOf me
|
|
12
12
|
* @constructor
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
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
17
|
*/
|
|
18
18
|
class TMXRenderer {
|
|
19
19
|
|
|
@@ -31,7 +31,7 @@ class TMXRenderer {
|
|
|
31
31
|
* @public
|
|
32
32
|
* @function
|
|
33
33
|
* @param {me.TMXTileMap|me.TMXLayer} component TMX Map or Layer
|
|
34
|
-
* @
|
|
34
|
+
* @returns {boolean}
|
|
35
35
|
*/
|
|
36
36
|
canRender(component) {
|
|
37
37
|
return (
|
|
@@ -52,7 +52,7 @@ class TMXRenderer {
|
|
|
52
52
|
* @public
|
|
53
53
|
* @function
|
|
54
54
|
* @param {me.TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
55
|
-
* @
|
|
55
|
+
* @returns {me.Bounds}
|
|
56
56
|
*/
|
|
57
57
|
getBounds(layer) {
|
|
58
58
|
var bounds = layer instanceof TMXLayer ? pool.pull("Bounds") : this.bounds;
|
|
@@ -69,10 +69,10 @@ class TMXRenderer {
|
|
|
69
69
|
* @name me.TMXRenderer#pixelToTileCoords
|
|
70
70
|
* @public
|
|
71
71
|
* @function
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {
|
|
74
|
-
* @param {me.Vector2d} [
|
|
75
|
-
* @
|
|
72
|
+
* @param {number} x X coordinate
|
|
73
|
+
* @param {number} y Y coordinate
|
|
74
|
+
* @param {me.Vector2d} [v] an optional vector object where to put the return values
|
|
75
|
+
* @returns {me.Vector2d}
|
|
76
76
|
*/
|
|
77
77
|
pixelToTileCoords(x, y, v) {
|
|
78
78
|
return v;
|
|
@@ -83,12 +83,12 @@ class TMXRenderer {
|
|
|
83
83
|
* @name me.TMXRenderer#tileToPixelCoords
|
|
84
84
|
* @public
|
|
85
85
|
* @function
|
|
86
|
-
* @param {
|
|
87
|
-
* @param {
|
|
88
|
-
* @param {me.Vector2d} [
|
|
89
|
-
* @
|
|
86
|
+
* @param {number} col tile horizontal position
|
|
87
|
+
* @param {number} row tile vertical position
|
|
88
|
+
* @param {me.Vector2d} [v] an optional vector object where to put the return values
|
|
89
|
+
* @returns {me.Vector2d}
|
|
90
90
|
*/
|
|
91
|
-
tileToPixelCoords(
|
|
91
|
+
tileToPixelCoords(col, row, v) {
|
|
92
92
|
return v;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -98,8 +98,8 @@ class TMXRenderer {
|
|
|
98
98
|
* @public
|
|
99
99
|
* @function
|
|
100
100
|
* @param {me.CanvasRenderer|me.WebGLRenderer} renderer a renderer object
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {
|
|
101
|
+
* @param {number} x X coordinate where to draw the tile
|
|
102
|
+
* @param {number} y Y coordinate where to draw the tile
|
|
103
103
|
* @param {me.Tile} tile the tile object to draw
|
|
104
104
|
*/
|
|
105
105
|
drawTile(renderer, x, y, tile) {
|
package/src/loader/loader.js
CHANGED
|
@@ -102,6 +102,9 @@ function preloadFontFace(data, onload, onerror) {
|
|
|
102
102
|
* @ignore
|
|
103
103
|
*/
|
|
104
104
|
function preloadTMX(tmxData, onload, onerror) {
|
|
105
|
+
/**
|
|
106
|
+
* @ignore
|
|
107
|
+
*/
|
|
105
108
|
function addToTMXList(data) {
|
|
106
109
|
// set the TMX content
|
|
107
110
|
tmxList[tmxData.name] = data;
|
|
@@ -337,7 +340,7 @@ var loader = {
|
|
|
337
340
|
* The "anonymous" keyword means that there will be no exchange of user credentials via cookies,
|
|
338
341
|
* client-side SSL certificates or HTTP authentication as described in the Terminology section of the CORS specification.<br>
|
|
339
342
|
* @public
|
|
340
|
-
* @type
|
|
343
|
+
* @type {string}
|
|
341
344
|
* @name crossOrigin
|
|
342
345
|
* @default undefined
|
|
343
346
|
* @memberOf me.loader
|
|
@@ -355,7 +358,7 @@ var loader = {
|
|
|
355
358
|
* indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies,
|
|
356
359
|
* authorization headers or TLS client certificates. Setting withCredentials has no effect on same-site requests.
|
|
357
360
|
* @public
|
|
358
|
-
* @type
|
|
361
|
+
* @type {boolean}
|
|
359
362
|
* @name withCredentials
|
|
360
363
|
* @default false
|
|
361
364
|
* @memberOf me.loader
|
|
@@ -411,8 +414,8 @@ var loader = {
|
|
|
411
414
|
* @memberOf me.loader
|
|
412
415
|
* @public
|
|
413
416
|
* @function
|
|
414
|
-
* @param {
|
|
415
|
-
* @param {
|
|
417
|
+
* @param {string} type "*", "audio", binary", "image", "json", "js", "tmx", "tsx"
|
|
418
|
+
* @param {string} [url="./"] default base URL
|
|
416
419
|
* @example
|
|
417
420
|
* // change the base URL relative address for audio assets
|
|
418
421
|
* me.loader.setBaseURL("audio", "data/audio/");
|
|
@@ -442,12 +445,12 @@ var loader = {
|
|
|
442
445
|
* @memberOf me.loader
|
|
443
446
|
* @public
|
|
444
447
|
* @function
|
|
445
|
-
* @param {
|
|
446
|
-
* @param {
|
|
447
|
-
* @param {
|
|
448
|
-
* @param {
|
|
449
|
-
* @param {
|
|
450
|
-
* @param {
|
|
448
|
+
* @param {object[]} res
|
|
449
|
+
* @param {string} res.name internal name of the resource
|
|
450
|
+
* @param {string} res.type "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
|
|
451
|
+
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
452
|
+
* @param {boolean} [res.stream] Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
453
|
+
* @param {Function} [onload=me.loader.onload] function to be called when all resources are loaded
|
|
451
454
|
* @param {boolean} [switchToLoadState=true] automatically switch to the loading screen
|
|
452
455
|
* @example
|
|
453
456
|
* game_resources = [
|
|
@@ -507,13 +510,14 @@ var loader = {
|
|
|
507
510
|
* @memberOf me.loader
|
|
508
511
|
* @public
|
|
509
512
|
* @function
|
|
510
|
-
* @param {
|
|
511
|
-
* @param {
|
|
512
|
-
* @param {
|
|
513
|
-
* @param {
|
|
514
|
-
* @param {
|
|
513
|
+
* @param {object} res
|
|
514
|
+
* @param {string} res.name internal name of the resource
|
|
515
|
+
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
516
|
+
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
517
|
+
* @param {boolean} [res.stream] Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
515
518
|
* @param {Function} onload function to be called when the resource is loaded
|
|
516
519
|
* @param {Function} onerror function to be called in case of error
|
|
520
|
+
* @returns {number} the amount of corresponding resource to be preloaded
|
|
517
521
|
* @example
|
|
518
522
|
* // load an image asset
|
|
519
523
|
* me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
|
|
@@ -576,8 +580,8 @@ var loader = {
|
|
|
576
580
|
* @memberOf me.loader
|
|
577
581
|
* @public
|
|
578
582
|
* @function
|
|
579
|
-
* @param {
|
|
580
|
-
* @
|
|
583
|
+
* @param {object} res
|
|
584
|
+
* @returns {boolean} true if unloaded
|
|
581
585
|
* @example me.loader.unload({name: "avatar", type:"image", src: "data/avatar.png"});
|
|
582
586
|
*/
|
|
583
587
|
unload(res) {
|
|
@@ -691,8 +695,8 @@ var loader = {
|
|
|
691
695
|
* @memberOf me.loader
|
|
692
696
|
* @public
|
|
693
697
|
* @function
|
|
694
|
-
* @param {
|
|
695
|
-
* @
|
|
698
|
+
* @param {string} elt name of the tmx/tsx element ("map1");
|
|
699
|
+
* @returns {object} requested element or null if not found
|
|
696
700
|
*/
|
|
697
701
|
getTMX(elt) {
|
|
698
702
|
// force as string
|
|
@@ -709,8 +713,8 @@ var loader = {
|
|
|
709
713
|
* @memberOf me.loader
|
|
710
714
|
* @public
|
|
711
715
|
* @function
|
|
712
|
-
* @param {
|
|
713
|
-
* @
|
|
716
|
+
* @param {string} elt name of the binary object ("ymTrack");
|
|
717
|
+
* @returns {object} requested element or null if not found
|
|
714
718
|
*/
|
|
715
719
|
getBinary(elt) {
|
|
716
720
|
// force as string
|
|
@@ -727,8 +731,8 @@ var loader = {
|
|
|
727
731
|
* @memberOf me.loader
|
|
728
732
|
* @public
|
|
729
733
|
* @function
|
|
730
|
-
* @param {
|
|
731
|
-
* @
|
|
734
|
+
* @param {string} image name of the Image element ("tileset-platformer");
|
|
735
|
+
* @returns {HTMLImageElement} requested element or null if not found
|
|
732
736
|
*/
|
|
733
737
|
getImage(image) {
|
|
734
738
|
// force as string and extract the base name
|
|
@@ -746,8 +750,8 @@ var loader = {
|
|
|
746
750
|
* @memberOf me.loader
|
|
747
751
|
* @public
|
|
748
752
|
* @function
|
|
749
|
-
* @param {
|
|
750
|
-
* @
|
|
753
|
+
* @param {string} elt name of the json file to load
|
|
754
|
+
* @returns {object}
|
|
751
755
|
*/
|
|
752
756
|
getJSON(elt) {
|
|
753
757
|
// force as string
|