melonjs 10.1.1 → 10.2.3
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 -10
- package/dist/melonjs.js +3114 -2866
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2588 -2498
- package/dist/melonjs.module.js +2694 -2479
- package/package.json +10 -11
- 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 +3 -3
- package/src/index.js +15 -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 +25 -33
- 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 +31 -27
- package/src/loader/loadingscreen.js +44 -75
- 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 +45 -51
- package/src/physics/bounds.js +36 -36
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -11
- package/src/physics/quadtree.js +18 -16
- 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 +158 -69
- package/src/renderable/renderable.js +68 -67
- 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 +8 -8
- package/src/state/state.js +56 -56
- 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 +118 -59
- 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 +85 -76
- package/src/video/texture_cache.js +11 -0
- package/src/video/video.js +31 -31
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +47 -46
- package/src/video/webgl/webgl_renderer.js +104 -104
|
@@ -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 = [
|
|
@@ -478,7 +481,7 @@ var loader = {
|
|
|
478
481
|
* // set all resources to be loaded
|
|
479
482
|
* me.loader.preload(game.resources, this.loaded.bind(this));
|
|
480
483
|
*/
|
|
481
|
-
preload(res, onload, switchToLoadState) {
|
|
484
|
+
preload(res, onload, switchToLoadState = true) {
|
|
482
485
|
// parse the resources
|
|
483
486
|
for (var i = 0; i < res.length; i++) {
|
|
484
487
|
resourceCount += this.load(
|
|
@@ -492,7 +495,7 @@ var loader = {
|
|
|
492
495
|
this.onload = onload;
|
|
493
496
|
}
|
|
494
497
|
|
|
495
|
-
if (switchToLoadState
|
|
498
|
+
if (switchToLoadState === true) {
|
|
496
499
|
// swith to the loading screen
|
|
497
500
|
state.change(state.LOADING);
|
|
498
501
|
}
|
|
@@ -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
|
|
@@ -71,9 +71,10 @@ class IconLogo extends Renderable {
|
|
|
71
71
|
super(x, y, 100, 85);
|
|
72
72
|
|
|
73
73
|
this.iconCanvas = createCanvas(
|
|
74
|
-
nextPowerOfTwo(this.width),
|
|
75
|
-
nextPowerOfTwo(this.height),
|
|
76
|
-
|
|
74
|
+
renderer.WebGLVersion > 1 ? this.width : nextPowerOfTwo(this.width),
|
|
75
|
+
renderer.WebGLVersion > 1 ? this.height : nextPowerOfTwo(this.height),
|
|
76
|
+
false
|
|
77
|
+
);
|
|
77
78
|
|
|
78
79
|
var context = renderer.getContext2d(this.iconCanvas);
|
|
79
80
|
|
|
@@ -114,70 +115,6 @@ class IconLogo extends Renderable {
|
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
117
|
|
|
117
|
-
// the melonJS Text Logo
|
|
118
|
-
class TextLogo extends Renderable {
|
|
119
|
-
/**
|
|
120
|
-
* @ignore
|
|
121
|
-
*/
|
|
122
|
-
constructor(w, h) {
|
|
123
|
-
super(0, 0, w, h);
|
|
124
|
-
|
|
125
|
-
this.textWidth = 0;
|
|
126
|
-
|
|
127
|
-
// offscreen cache canvas
|
|
128
|
-
this.fontCanvas = createCanvas(256, 64, true);
|
|
129
|
-
this.drawFont(renderer.getContext2d(this.fontCanvas));
|
|
130
|
-
|
|
131
|
-
this.anchorPoint.set(0, 0.5);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
drawFont(context) {
|
|
135
|
-
var logo1 = pool.pull("Text", 0, 0, {
|
|
136
|
-
font: "century gothic",
|
|
137
|
-
size: 32,
|
|
138
|
-
fillStyle: "white",
|
|
139
|
-
textAlign: "middle",
|
|
140
|
-
textBaseline : "top",
|
|
141
|
-
text: "melon"
|
|
142
|
-
});
|
|
143
|
-
var logo2 = pool.pull("Text", 0, 0, {
|
|
144
|
-
font: "century gothic",
|
|
145
|
-
size: 32,
|
|
146
|
-
fillStyle: "#55aa00",
|
|
147
|
-
textAlign: "middle",
|
|
148
|
-
textBaseline : "top",
|
|
149
|
-
bold: true,
|
|
150
|
-
text: "JS"
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// compute both logo respective size
|
|
155
|
-
var logo1_width = logo1.measureText(context).width;
|
|
156
|
-
var logo2_width = logo2.measureText(context).width;
|
|
157
|
-
|
|
158
|
-
this.textWidth = logo1_width + logo2_width;
|
|
159
|
-
|
|
160
|
-
// calculate the final rendering position
|
|
161
|
-
this.pos.x = Math.round(this.width - this.textWidth / 2);
|
|
162
|
-
this.pos.y = Math.round(this.height + 16);
|
|
163
|
-
|
|
164
|
-
// use the private _drawFont method to directly draw on the canvas context
|
|
165
|
-
logo1._drawFont(context, ["melon"], 0, 0);
|
|
166
|
-
logo2._drawFont(context, ["JS"], logo1_width, 0);
|
|
167
|
-
|
|
168
|
-
// put them back into the object pool
|
|
169
|
-
pool.push(logo1);
|
|
170
|
-
pool.push(logo2);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @ignore
|
|
175
|
-
*/
|
|
176
|
-
draw(renderer) {
|
|
177
|
-
renderer.drawImage(this.fontCanvas, Math.round((renderer.getWidth() - this.textWidth) / 2), this.pos.y);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
};
|
|
181
118
|
|
|
182
119
|
/**
|
|
183
120
|
* a default loading screen
|
|
@@ -185,12 +122,12 @@ class TextLogo extends Renderable {
|
|
|
185
122
|
* @ignore
|
|
186
123
|
* @constructor
|
|
187
124
|
*/
|
|
188
|
-
|
|
125
|
+
class DefaultLoadingScreen extends Stage {
|
|
189
126
|
/**
|
|
190
127
|
* call when the loader is resetted
|
|
191
128
|
* @ignore
|
|
192
129
|
*/
|
|
193
|
-
onResetEvent
|
|
130
|
+
onResetEvent() {
|
|
194
131
|
var barHeight = 8;
|
|
195
132
|
|
|
196
133
|
// clear the background
|
|
@@ -211,12 +148,44 @@ var defaultLoadingScreen = new Stage({
|
|
|
211
148
|
|
|
212
149
|
), 2);
|
|
213
150
|
|
|
151
|
+
var logo1 = pool.pull("Text",
|
|
152
|
+
renderer.getWidth() / 2,
|
|
153
|
+
(renderer.getHeight() / 2) + 16, {
|
|
154
|
+
font: "century gothic",
|
|
155
|
+
size: 32,
|
|
156
|
+
fillStyle: "white",
|
|
157
|
+
textAlign: "left",
|
|
158
|
+
textBaseline : "top",
|
|
159
|
+
text: "melon",
|
|
160
|
+
offScreenCanvas: renderer.WebGLVersion >= 1
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
logo1.anchorPoint.set(0, 0);
|
|
164
|
+
|
|
165
|
+
var logo2 = pool.pull("Text",
|
|
166
|
+
renderer.getWidth() / 2,
|
|
167
|
+
(renderer.getHeight() / 2) + 16, {
|
|
168
|
+
font: "century gothic",
|
|
169
|
+
size: 32,
|
|
170
|
+
fillStyle: "#55aa00",
|
|
171
|
+
textAlign: "left",
|
|
172
|
+
textBaseline : "top",
|
|
173
|
+
bold: true,
|
|
174
|
+
text: "JS",
|
|
175
|
+
offScreenCanvas: renderer.WebGLVersion >= 1
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
logo2.anchorPoint.set(0, 0);
|
|
179
|
+
|
|
180
|
+
// adjust position of both text
|
|
181
|
+
var text_width = logo1.getBounds().width + logo2.getBounds().width;
|
|
182
|
+
logo1.pos.x = renderer.getWidth() / 2 - text_width / 2;
|
|
183
|
+
logo2.pos.x = logo1.pos.x + logo1.getBounds().width;
|
|
184
|
+
|
|
214
185
|
// melonJS text
|
|
215
|
-
world.addChild(
|
|
216
|
-
|
|
217
|
-
renderer.getHeight()
|
|
218
|
-
), 2);
|
|
186
|
+
world.addChild(logo1, 2);
|
|
187
|
+
world.addChild(logo2, 2);
|
|
219
188
|
}
|
|
220
|
-
}
|
|
189
|
+
};
|
|
221
190
|
|
|
222
|
-
export default
|
|
191
|
+
export default DefaultLoadingScreen;
|