melonjs 11.0.0 → 12.0.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 +2 -0
- package/dist/melonjs.js +2684 -2604
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +0 -20
- package/dist/melonjs.module.js +2689 -2612
- package/package.json +4 -3
- package/src/audio/audio.js +5 -5
- package/src/loader/loadingscreen.js +17 -103
- package/src/loader/melonjs_logo.png +0 -0
- package/src/polyfill/index.js +4 -0
- package/src/text/bitmaptext.js +1 -2
- package/src/text/text.js +1 -2
- package/src/text/textmetrics.js +1 -2
- package/src/utils/string.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"keywords": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@teppeis/multimaps": "^2.0.0",
|
|
58
|
-
"core-js": "^3.23.
|
|
58
|
+
"core-js": "^3.23.3",
|
|
59
59
|
"earcut": "2.2.3",
|
|
60
60
|
"eventemitter3": "^4.0.7",
|
|
61
61
|
"howler": "2.2.3"
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@melonjs/webdoc-theme": "^1.1.1",
|
|
65
65
|
"@rollup/plugin-buble": "^0.21.3",
|
|
66
|
-
"@rollup/plugin-commonjs": "^22.0.
|
|
66
|
+
"@rollup/plugin-commonjs": "^22.0.1",
|
|
67
|
+
"@rollup/plugin-image": "^2.1.1",
|
|
67
68
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
68
69
|
"@rollup/plugin-replace": "^4.0.0",
|
|
69
70
|
"@types/offscreencanvas": "^2019.7.0",
|
package/src/audio/audio.js
CHANGED
|
@@ -11,31 +11,31 @@ import loader from "./../loader/loader.js";
|
|
|
11
11
|
* audio channel list
|
|
12
12
|
* @ignore
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
let audioTracks = {};
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* current active track
|
|
18
18
|
* @ignore
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
let current_track_id = null;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* error retry counter
|
|
24
24
|
* @ignore
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
let retry_counter = 0;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* list of active audio formats
|
|
30
30
|
* @ignore
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
let audioExts = [];
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* event listener callback on load error
|
|
36
36
|
* @ignore
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
let soundLoadError = function (sound_name, onerror_cb) {
|
|
39
39
|
// check the retry counter
|
|
40
40
|
if (retry_counter++ > 3) {
|
|
41
41
|
// something went wrong
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { world, viewport } from "./../game.js";
|
|
2
2
|
import { renderer } from "./../video/video.js";
|
|
3
3
|
import * as event from "./../system/event.js";
|
|
4
|
-
import {nextPowerOfTwo} from "./../math/math.js";
|
|
5
|
-
import pool from "./../system/pooling.js";
|
|
6
4
|
import Renderable from "./../renderable/renderable.js";
|
|
5
|
+
import Sprite from "./../renderable/sprite.js";
|
|
7
6
|
import Stage from "./../state/stage.js";
|
|
7
|
+
import melonjs_logo from "./melonjs_logo.png";
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
// a basic progress bar object
|
|
@@ -61,70 +61,22 @@ class ProgressBar extends Renderable {
|
|
|
61
61
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
/**
|
|
65
|
+
* the melonJS Logo
|
|
66
|
+
* @ignore
|
|
67
|
+
*/
|
|
68
|
+
class IconLogo extends Sprite {
|
|
69
69
|
constructor(x, y) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var context = this.iconTexture.context;
|
|
79
|
-
|
|
80
|
-
context.beginPath();
|
|
81
|
-
context.moveTo(0.7, 48.9);
|
|
82
|
-
context.bezierCurveTo(10.8, 68.9, 38.4, 75.8, 62.2, 64.5);
|
|
83
|
-
context.bezierCurveTo(86.1, 53.1, 97.2, 27.7, 87.0, 7.7);
|
|
84
|
-
context.lineTo(87.0, 7.7);
|
|
85
|
-
context.bezierCurveTo(89.9, 15.4, 73.9, 30.2, 50.5, 41.4);
|
|
86
|
-
context.bezierCurveTo(27.1, 52.5, 5.2, 55.8, 0.7, 48.9);
|
|
87
|
-
context.lineTo(0.7, 48.9);
|
|
88
|
-
context.closePath();
|
|
89
|
-
context.fillStyle = "rgb(255, 255, 255)";
|
|
90
|
-
context.fill();
|
|
91
|
-
|
|
92
|
-
context.beginPath();
|
|
93
|
-
context.moveTo(84.0, 7.0);
|
|
94
|
-
context.bezierCurveTo(87.6, 14.7, 72.5, 30.2, 50.2, 41.6);
|
|
95
|
-
context.bezierCurveTo(27.9, 53.0, 6.9, 55.9, 3.2, 48.2);
|
|
96
|
-
context.bezierCurveTo(-0.5, 40.4, 14.6, 24.9, 36.9, 13.5);
|
|
97
|
-
context.bezierCurveTo(59.2, 2.2, 80.3, -0.8, 84.0, 7.0);
|
|
98
|
-
context.lineTo(84.0, 7.0);
|
|
99
|
-
context.closePath();
|
|
100
|
-
context.lineWidth = 5.3;
|
|
101
|
-
context.strokeStyle = "rgb(255, 255, 255)";
|
|
102
|
-
context.lineJoin = "miter";
|
|
103
|
-
context.miterLimit = 4.0;
|
|
104
|
-
context.stroke();
|
|
105
|
-
|
|
106
|
-
this.anchorPoint.set(0.5, 0.5);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @ignore
|
|
111
|
-
*/
|
|
112
|
-
draw(renderer) {
|
|
113
|
-
renderer.drawImage(this.iconTexture.canvas, renderer.getWidth() / 2, this.pos.y);
|
|
70
|
+
// TODO: create a sprite or texture from a Base64 encoded image
|
|
71
|
+
var image = new Image();
|
|
72
|
+
image.src = melonjs_logo;
|
|
73
|
+
super(x, y, {
|
|
74
|
+
image : image,
|
|
75
|
+
framewidth : 256,
|
|
76
|
+
frameheight : 256
|
|
77
|
+
});
|
|
114
78
|
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Destroy function
|
|
118
|
-
* @ignore
|
|
119
|
-
*/
|
|
120
|
-
destroy() {
|
|
121
|
-
// call the parent destroy method
|
|
122
|
-
super.destroy(arguments);
|
|
123
|
-
pool.push(this.iconTexture);
|
|
124
|
-
this.iconTexture = undefined;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
79
|
+
}
|
|
128
80
|
|
|
129
81
|
/**
|
|
130
82
|
* a default loading screen
|
|
@@ -152,47 +104,9 @@ class DefaultLoadingScreen extends Stage {
|
|
|
152
104
|
// melonJS logo
|
|
153
105
|
world.addChild(new IconLogo(
|
|
154
106
|
renderer.getWidth() / 2,
|
|
155
|
-
(renderer.getHeight() / 2)
|
|
107
|
+
(renderer.getHeight() / 2)
|
|
156
108
|
|
|
157
109
|
), 2);
|
|
158
|
-
|
|
159
|
-
var logo1 = pool.pull("Text",
|
|
160
|
-
renderer.getWidth() / 2,
|
|
161
|
-
(renderer.getHeight() / 2) + 16, {
|
|
162
|
-
font: "century gothic",
|
|
163
|
-
size: 32,
|
|
164
|
-
fillStyle: "white",
|
|
165
|
-
textAlign: "left",
|
|
166
|
-
textBaseline : "top",
|
|
167
|
-
text: "melon",
|
|
168
|
-
offScreenCanvas: renderer.WebGLVersion >= 1
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
logo1.anchorPoint.set(0, 0);
|
|
172
|
-
|
|
173
|
-
var logo2 = pool.pull("Text",
|
|
174
|
-
renderer.getWidth() / 2,
|
|
175
|
-
(renderer.getHeight() / 2) + 16, {
|
|
176
|
-
font: "century gothic",
|
|
177
|
-
size: 32,
|
|
178
|
-
fillStyle: "#55aa00",
|
|
179
|
-
textAlign: "left",
|
|
180
|
-
textBaseline : "top",
|
|
181
|
-
bold: true,
|
|
182
|
-
text: "JS",
|
|
183
|
-
offScreenCanvas: renderer.WebGLVersion >= 1
|
|
184
|
-
}
|
|
185
|
-
);
|
|
186
|
-
logo2.anchorPoint.set(0, 0);
|
|
187
|
-
|
|
188
|
-
// adjust position of both text
|
|
189
|
-
var text_width = logo1.getBounds().width + logo2.getBounds().width;
|
|
190
|
-
logo1.pos.x = renderer.getWidth() / 2 - text_width / 2;
|
|
191
|
-
logo2.pos.x = logo1.pos.x + logo1.getBounds().width;
|
|
192
|
-
|
|
193
|
-
// melonJS text
|
|
194
|
-
world.addChild(logo1, 2);
|
|
195
|
-
world.addChild(logo2, 2);
|
|
196
110
|
}
|
|
197
111
|
};
|
|
198
112
|
|
|
Binary file
|
package/src/polyfill/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// https://github.com/melonjs/melonJS/issues/1092
|
|
2
2
|
import "core-js/proposals/global-this";
|
|
3
3
|
|
|
4
|
+
// es10 string trim functions
|
|
5
|
+
import "core-js/es/string/trim-left";
|
|
6
|
+
import "core-js/es/string/trim-right";
|
|
7
|
+
|
|
4
8
|
// "built-in" polyfills
|
|
5
9
|
import "./console.js";
|
|
6
10
|
import "./performance.js";
|
package/src/text/bitmaptext.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Color from "./../math/color.js";
|
|
2
|
-
import * as stringUtil from "./../utils/string.js";
|
|
3
2
|
import pool from "./../system/pooling.js";
|
|
4
3
|
import loader from "./../loader/loader.js";
|
|
5
4
|
import Renderable from "./../renderable/renderable.js";
|
|
@@ -254,7 +253,7 @@ class BitmapText extends Renderable {
|
|
|
254
253
|
|
|
255
254
|
for (var i = 0; i < this._text.length; i++) {
|
|
256
255
|
x = lX;
|
|
257
|
-
var string =
|
|
256
|
+
var string = this._text[i].trimRight();
|
|
258
257
|
// adjust x pos based on alignment value
|
|
259
258
|
var stringWidth = this.metrics.lineWidth(string);
|
|
260
259
|
switch (this.textAlign) {
|
package/src/text/text.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Color from "./../math/color.js";
|
|
2
2
|
import WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
3
3
|
import { renderer as globalRenderer } from "./../video/video.js";
|
|
4
|
-
import { trimRight } from "./../utils/string.js";
|
|
5
4
|
import pool from "./../system/pooling.js";
|
|
6
5
|
import Renderable from "./../renderable/renderable.js";
|
|
7
6
|
import { nextPowerOfTwo } from "./../math/math.js";
|
|
@@ -423,7 +422,7 @@ class Text extends Renderable {
|
|
|
423
422
|
setContextStyle(context, this, stroke);
|
|
424
423
|
|
|
425
424
|
for (var i = 0; i < text.length; i++) {
|
|
426
|
-
var string =
|
|
425
|
+
var string = text[i].trimRight();
|
|
427
426
|
// draw the string
|
|
428
427
|
context[stroke ? "strokeText" : "fillText"](string, x, y);
|
|
429
428
|
// add leading space
|
package/src/text/textmetrics.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Bounds from "./../physics/bounds.js";
|
|
2
|
-
import { trimRight } from "./../utils/string.js";
|
|
3
2
|
import Text from "./text.js";
|
|
4
3
|
import setContextStyle from "./textstyle.js";
|
|
5
4
|
|
|
@@ -92,7 +91,7 @@ class TextMetrics extends Bounds {
|
|
|
92
91
|
this.width = this.height = 0;
|
|
93
92
|
|
|
94
93
|
for (var i = 0; i < strings.length; i++) {
|
|
95
|
-
this.width = Math.max(this.lineWidth(
|
|
94
|
+
this.width = Math.max(this.lineWidth(strings[i].trimRight(), context), this.width);
|
|
96
95
|
this.height += this.lineHeight();
|
|
97
96
|
}
|
|
98
97
|
this.width = Math.ceil(this.width);
|
package/src/utils/string.js
CHANGED
|
@@ -15,30 +15,6 @@ export function capitalize(str) {
|
|
|
15
15
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* returns the string stripped of whitespace from the left.
|
|
20
|
-
* @public
|
|
21
|
-
* @memberof utils.string
|
|
22
|
-
* @name trimLeft
|
|
23
|
-
* @param {string} str the string to be trimmed
|
|
24
|
-
* @returns {string} trimmed string
|
|
25
|
-
*/
|
|
26
|
-
export function trimLeft(str) {
|
|
27
|
-
return str.replace(/^\s+/, "");
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* returns the string stripped of whitespace from the right.
|
|
32
|
-
* @public
|
|
33
|
-
* @memberof utils.string
|
|
34
|
-
* @name trimRight
|
|
35
|
-
* @param {string} str the string to be trimmed
|
|
36
|
-
* @returns {string} trimmed string
|
|
37
|
-
*/
|
|
38
|
-
export function trimRight(str) {
|
|
39
|
-
return str.replace(/\s+$/, "");
|
|
40
|
-
};
|
|
41
|
-
|
|
42
18
|
/**
|
|
43
19
|
* returns true if the given string contains a numeric integer or float value
|
|
44
20
|
* @public
|