melonjs 13.3.0 → 14.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 +4 -6
- package/dist/melonjs.module.d.ts +13108 -11652
- package/dist/melonjs.module.js +657 -181
- package/package.json +23 -23
- package/src/application/application.js +3 -3
- package/src/audio/audio.js +27 -27
- package/src/camera/camera2d.js +1 -2
- package/src/entity/entity.js +1 -2
- package/src/geometries/ellipse.js +1 -2
- package/src/geometries/line.js +2 -3
- package/src/geometries/poly.js +2 -2
- package/src/geometries/rectangle.js +1 -3
- package/src/geometries/roundrect.js +1 -2
- package/src/index.js +8 -4
- package/src/input/gamepad.js +12 -12
- package/src/input/keyboard.js +8 -8
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +9 -9
- package/src/lang/deprecated.js +21 -2
- package/src/level/level.js +2 -2
- package/src/level/tiled/TMXGroup.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXTile.js +2 -2
- package/src/level/tiled/TMXTileMap.js +4 -4
- package/src/level/tiled/TMXTileset.js +2 -2
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +7 -7
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/loader.js +9 -9
- package/src/loader/loadingscreen.js +2 -2
- package/src/math/color.js +3 -3
- package/src/math/math.js +10 -10
- package/src/math/matrix2.js +1 -1
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +1 -1
- package/src/math/observable_vector3.js +1 -1
- package/src/math/vector2.js +1 -1
- package/src/math/vector3.js +1 -1
- package/src/particles/emitter.js +2 -2
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +2 -2
- package/src/physics/bounds.js +1 -1
- package/src/physics/detector.js +3 -3
- package/src/physics/quadtree.js +2 -2
- package/src/physics/world.js +2 -2
- package/src/polyfill/performance.js +1 -1
- package/src/polyfill/requestAnimationFrame.js +1 -1
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +1 -1
- package/src/renderable/container.js +10 -6
- package/src/renderable/dragndrop.js +2 -2
- package/src/renderable/imagelayer.js +1 -2
- package/src/renderable/light2d.js +1 -1
- package/src/renderable/nineslicesprite.js +1 -2
- package/src/renderable/renderable.js +1 -3
- package/src/renderable/sprite.js +3 -4
- package/src/renderable/trigger.js +3 -4
- package/src/renderable/ui/uibaseelement.js +204 -0
- package/src/renderable/{GUI.js → ui/uispriteelement.js} +8 -35
- package/src/renderable/ui/uitextbutton.js +121 -0
- package/src/state/stage.js +4 -5
- package/src/system/device.js +27 -27
- package/src/system/dom.js +1 -1
- package/src/system/event.js +4 -4
- package/src/system/pooling.js +2 -3
- package/src/system/save.js +2 -2
- package/src/system/timer.js +1 -1
- package/src/text/bitmaptext.js +27 -21
- package/src/text/bitmaptextdata.js +4 -7
- package/src/text/glyph.js +1 -2
- package/src/text/text.js +2 -3
- package/src/text/textmetrics.js +5 -3
- package/src/text/textstyle.js +1 -1
- package/src/tweens/tween.js +2 -3
- package/src/utils/agent.js +4 -4
- package/src/utils/array.js +3 -3
- package/src/utils/file.js +2 -2
- package/src/utils/function.js +3 -3
- package/src/utils/string.js +5 -5
- package/src/utils/utils.js +2 -2
- package/src/video/canvas/canvas_renderer.js +1 -2
- package/src/video/renderer.js +2 -3
- package/src/video/texture/atlas.js +2 -2
- package/src/video/texture/cache.js +1 -2
- package/src/video/video.js +12 -14
- package/src/video/webgl/buffer/vertex.js +1 -2
- package/src/video/webgl/glshader.js +1 -2
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/precision.js +1 -1
- package/src/video/webgl/utils/program.js +2 -2
- package/src/video/webgl/utils/string.js +1 -1
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_compositor.js +1 -2
- package/src/video/webgl/webgl_renderer.js +1 -2
- package/dist/melonjs.js +0 -37899
- package/dist/melonjs.min.js +0 -29
package/src/system/device.js
CHANGED
|
@@ -22,7 +22,7 @@ function disableSwipeFn(e) {
|
|
|
22
22
|
globalThis.scroll(0, 0);
|
|
23
23
|
}
|
|
24
24
|
return false;
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
|
|
27
27
|
function hasLocalStorage() {
|
|
28
28
|
try {
|
|
@@ -51,7 +51,7 @@ function onDeviceMotion(e) {
|
|
|
51
51
|
accelerationX = e.accelerationIncludingGravity.x;
|
|
52
52
|
accelerationY = e.accelerationIncludingGravity.y;
|
|
53
53
|
accelerationZ = e.accelerationIncludingGravity.z;
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* used by [un]watchDeviceOrientation()
|
|
@@ -60,7 +60,7 @@ export function onDeviceRotate(e) {
|
|
|
60
60
|
gamma = e.gamma;
|
|
61
61
|
beta = e.beta;
|
|
62
62
|
alpha = e.alpha;
|
|
63
|
-
}
|
|
63
|
+
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* the device platform type
|
|
@@ -431,7 +431,7 @@ export let stopOnBlur = false;
|
|
|
431
431
|
*/
|
|
432
432
|
export function onReady(fn) {
|
|
433
433
|
DOMContentLoaded(fn);
|
|
434
|
-
}
|
|
434
|
+
}
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
437
|
* enable/disable swipe on WebView.
|
|
@@ -451,7 +451,7 @@ export function enableSwipe(enable) {
|
|
|
451
451
|
globalThis.document.addEventListener(moveEvent, disableSwipeFn, { passive: false });
|
|
452
452
|
swipeEnabled = false;
|
|
453
453
|
}
|
|
454
|
-
}
|
|
454
|
+
}
|
|
455
455
|
|
|
456
456
|
/**
|
|
457
457
|
* Returns true if the browser/device is in full screen mode.
|
|
@@ -466,7 +466,7 @@ export function isFullscreen() {
|
|
|
466
466
|
} else {
|
|
467
467
|
return false;
|
|
468
468
|
}
|
|
469
|
-
}
|
|
469
|
+
}
|
|
470
470
|
|
|
471
471
|
/**
|
|
472
472
|
* Triggers a fullscreen request. Requires fullscreen support from the browser/device.
|
|
@@ -492,7 +492,7 @@ export function requestFullscreen(element) {
|
|
|
492
492
|
element.requestFullscreen = prefixed("requestFullscreen", element) || element.mozRequestFullScreen;
|
|
493
493
|
element.requestFullscreen();
|
|
494
494
|
}
|
|
495
|
-
}
|
|
495
|
+
}
|
|
496
496
|
|
|
497
497
|
/**
|
|
498
498
|
* Exit fullscreen mode. Requires fullscreen support from the browser/device.
|
|
@@ -504,7 +504,7 @@ export function exitFullscreen() {
|
|
|
504
504
|
if (hasFullscreenSupport && isFullscreen()) {
|
|
505
505
|
document.exitFullscreen();
|
|
506
506
|
}
|
|
507
|
-
}
|
|
507
|
+
}
|
|
508
508
|
|
|
509
509
|
/**
|
|
510
510
|
* Return a string representing the orientation of the device screen.
|
|
@@ -540,7 +540,7 @@ export function getScreenOrientation() {
|
|
|
540
540
|
|
|
541
541
|
// fallback to window size check
|
|
542
542
|
return (globalThis.outerWidth > globalThis.outerHeight) ? LANDSCAPE : PORTRAIT;
|
|
543
|
-
}
|
|
543
|
+
}
|
|
544
544
|
|
|
545
545
|
/**
|
|
546
546
|
* locks the device screen into the specified orientation.<br>
|
|
@@ -561,7 +561,7 @@ export function lockOrientation(orientation) {
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
return false;
|
|
564
|
-
}
|
|
564
|
+
}
|
|
565
565
|
|
|
566
566
|
/**
|
|
567
567
|
* unlocks the device screen into the specified orientation.<br>
|
|
@@ -581,7 +581,7 @@ export function unlockOrientation() {
|
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
583
|
return false;
|
|
584
|
-
}
|
|
584
|
+
}
|
|
585
585
|
|
|
586
586
|
/**
|
|
587
587
|
* return true if the device screen orientation is in Portrait mode
|
|
@@ -592,7 +592,7 @@ export function unlockOrientation() {
|
|
|
592
592
|
*/
|
|
593
593
|
export function isPortrait() {
|
|
594
594
|
return getScreenOrientation().includes("portrait");
|
|
595
|
-
}
|
|
595
|
+
}
|
|
596
596
|
|
|
597
597
|
/**
|
|
598
598
|
* return true if the device screen orientation is in Portrait mode
|
|
@@ -603,7 +603,7 @@ export function isPortrait() {
|
|
|
603
603
|
*/
|
|
604
604
|
export function isLandscape() {
|
|
605
605
|
return getScreenOrientation().includes("landscape");
|
|
606
|
-
}
|
|
606
|
+
}
|
|
607
607
|
|
|
608
608
|
/**
|
|
609
609
|
* return the device storage
|
|
@@ -622,7 +622,7 @@ export function getStorage(type = "local") {
|
|
|
622
622
|
default :
|
|
623
623
|
throw new Error("storage type " + type + " not supported");
|
|
624
624
|
}
|
|
625
|
-
}
|
|
625
|
+
}
|
|
626
626
|
|
|
627
627
|
/**
|
|
628
628
|
* return the parent DOM element for the given parent name or HTMLElement object
|
|
@@ -640,7 +640,7 @@ export function getParentElement(element) {
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
return target;
|
|
643
|
-
}
|
|
643
|
+
}
|
|
644
644
|
|
|
645
645
|
/**
|
|
646
646
|
* return the DOM element for the given element name or HTMLElement object
|
|
@@ -668,7 +668,7 @@ export function getElement(element) {
|
|
|
668
668
|
}
|
|
669
669
|
|
|
670
670
|
return target;
|
|
671
|
-
}
|
|
671
|
+
}
|
|
672
672
|
|
|
673
673
|
/**
|
|
674
674
|
* returns the size of the given HTMLElement and its position relative to the viewport
|
|
@@ -687,8 +687,8 @@ export function getElementBounds(element) {
|
|
|
687
687
|
domRect.width = domRect.right = globalThis.innerWidth;
|
|
688
688
|
domRect.height = domRect.bottom = globalThis.innerHeight;
|
|
689
689
|
return domRect;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
692
|
|
|
693
693
|
/**
|
|
694
694
|
* returns the size of the given HTMLElement Parent and its position relative to the viewport
|
|
@@ -702,7 +702,7 @@ export function getElementBounds(element) {
|
|
|
702
702
|
*/
|
|
703
703
|
export function getParentBounds(element) {
|
|
704
704
|
return getElementBounds(getParentElement(element));
|
|
705
|
-
}
|
|
705
|
+
}
|
|
706
706
|
|
|
707
707
|
/**
|
|
708
708
|
* returns true if the device supports WebGL
|
|
@@ -727,7 +727,7 @@ export function isWebGLSupported(options) {
|
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
return _supported;
|
|
730
|
-
}
|
|
730
|
+
}
|
|
731
731
|
|
|
732
732
|
/**
|
|
733
733
|
* return the highest precision format supported by this device for GL Shaders
|
|
@@ -747,7 +747,7 @@ export function getMaxShaderPrecision(gl) {
|
|
|
747
747
|
return "mediump";
|
|
748
748
|
}
|
|
749
749
|
return "lowp";
|
|
750
|
-
}
|
|
750
|
+
}
|
|
751
751
|
|
|
752
752
|
/**
|
|
753
753
|
* Makes a request to bring this device window to the front.
|
|
@@ -763,7 +763,7 @@ export function focus() {
|
|
|
763
763
|
if (typeof (globalThis.focus) === "function") {
|
|
764
764
|
globalThis.focus();
|
|
765
765
|
}
|
|
766
|
-
}
|
|
766
|
+
}
|
|
767
767
|
|
|
768
768
|
/**
|
|
769
769
|
* Enable monitor of the device accelerator to detect the amount of physical force of acceleration the device is receiving.
|
|
@@ -806,7 +806,7 @@ export function watchAccelerometer() {
|
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
return accelInitialized;
|
|
809
|
-
}
|
|
809
|
+
}
|
|
810
810
|
|
|
811
811
|
/**
|
|
812
812
|
* unwatch Accelerometor event
|
|
@@ -820,7 +820,7 @@ export function unwatchAccelerometer() {
|
|
|
820
820
|
globalThis.removeEventListener("devicemotion", onDeviceMotion, false);
|
|
821
821
|
accelInitialized = false;
|
|
822
822
|
}
|
|
823
|
-
}
|
|
823
|
+
}
|
|
824
824
|
|
|
825
825
|
/**
|
|
826
826
|
* Enable monitor of the device orientation to detect the current orientation of the device as compared to the Earth coordinate frame.
|
|
@@ -859,7 +859,7 @@ export function watchDeviceOrientation() {
|
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
861
|
return deviceOrientationInitialized;
|
|
862
|
-
}
|
|
862
|
+
}
|
|
863
863
|
|
|
864
864
|
/**
|
|
865
865
|
* unwatch Device orientation event
|
|
@@ -872,7 +872,7 @@ export function unwatchDeviceOrientation() {
|
|
|
872
872
|
globalThis.removeEventListener("deviceorientation", onDeviceRotate, false);
|
|
873
873
|
deviceOrientationInitialized = false;
|
|
874
874
|
}
|
|
875
|
-
}
|
|
875
|
+
}
|
|
876
876
|
|
|
877
877
|
/**
|
|
878
878
|
* the vibrate method pulses the vibration hardware on the device, <br>
|
|
@@ -897,4 +897,4 @@ export function vibrate(pattern) {
|
|
|
897
897
|
if (typeof globalThis.navigator !== "undefined" && typeof globalThis.navigator.vibrate === "function") {
|
|
898
898
|
globalThis.navigator.vibrate(pattern);
|
|
899
899
|
}
|
|
900
|
-
}
|
|
900
|
+
}
|
package/src/system/dom.js
CHANGED
package/src/system/event.js
CHANGED
|
@@ -481,7 +481,7 @@ export const ONCONTEXT_RESTORED = "renderer.contextrestored";
|
|
|
481
481
|
*/
|
|
482
482
|
export function emit(eventName, ...args) {
|
|
483
483
|
return eventEmitter.emit(eventName, ...args);
|
|
484
|
-
}
|
|
484
|
+
}
|
|
485
485
|
|
|
486
486
|
/**
|
|
487
487
|
* Add a listener for a given event.
|
|
@@ -496,7 +496,7 @@ export function emit(eventName, ...args) {
|
|
|
496
496
|
*/
|
|
497
497
|
export function on(eventName, listener, context) {
|
|
498
498
|
return eventEmitter.on(eventName, listener, context);
|
|
499
|
-
}
|
|
499
|
+
}
|
|
500
500
|
|
|
501
501
|
/**
|
|
502
502
|
* Add a one-time listener for a given event.
|
|
@@ -511,7 +511,7 @@ export function on(eventName, listener, context) {
|
|
|
511
511
|
*/
|
|
512
512
|
export function once(eventName, listener, context) {
|
|
513
513
|
return eventEmitter.once(eventName, listener, context);
|
|
514
|
-
}
|
|
514
|
+
}
|
|
515
515
|
|
|
516
516
|
/**
|
|
517
517
|
* remove the given listener for a given event.
|
|
@@ -525,4 +525,4 @@ export function once(eventName, listener, context) {
|
|
|
525
525
|
*/
|
|
526
526
|
export function off(eventName, listener) {
|
|
527
527
|
return eventEmitter.off(eventName, listener);
|
|
528
|
-
}
|
|
528
|
+
}
|
package/src/system/pooling.js
CHANGED
|
@@ -149,7 +149,7 @@ class ObjectPool {
|
|
|
149
149
|
*/
|
|
150
150
|
exists(name) {
|
|
151
151
|
return name in this.objectClass;
|
|
152
|
-
}
|
|
152
|
+
}
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* Check if an object is poolable
|
|
@@ -178,8 +178,7 @@ class ObjectPool {
|
|
|
178
178
|
getInstanceCount() {
|
|
179
179
|
return this.instance_counter;
|
|
180
180
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
181
|
+
}
|
|
183
182
|
|
|
184
183
|
var pool = new ObjectPool();
|
|
185
184
|
|
package/src/system/save.js
CHANGED
|
@@ -61,7 +61,7 @@ event.on(event.BOOT, () => {
|
|
|
61
61
|
|
|
62
62
|
if (typeof me_save_content === "string" && me_save_content.length > 0) {
|
|
63
63
|
var keys = JSON.parse(me_save_content) || [];
|
|
64
|
-
keys.forEach(
|
|
64
|
+
keys.forEach((key) => {
|
|
65
65
|
data[key] = JSON.parse(globalThis.localStorage.getItem("me.save." + key));
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -84,7 +84,7 @@ var save = {
|
|
|
84
84
|
add(props) {
|
|
85
85
|
var obj = save;
|
|
86
86
|
|
|
87
|
-
Object.keys(props).forEach(
|
|
87
|
+
Object.keys(props).forEach((key) => {
|
|
88
88
|
if (isReserved(key)) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
package/src/system/timer.js
CHANGED
package/src/text/bitmaptext.js
CHANGED
|
@@ -109,7 +109,7 @@ class BitmapText extends Renderable {
|
|
|
109
109
|
// if starting/includes "info face" the whole data string was passed as parameter
|
|
110
110
|
(settings.fontData.includes("info face")) ? settings.fontData : loader.getBinary(settings.fontData)
|
|
111
111
|
);
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
|
|
114
114
|
// if floating was specified through settings
|
|
115
115
|
if (typeof settings.floating !== "undefined") {
|
|
@@ -302,25 +302,32 @@ class BitmapText extends Renderable {
|
|
|
302
302
|
// calculate the char index
|
|
303
303
|
var ch = string.charCodeAt(c);
|
|
304
304
|
var glyph = this.fontData.glyphs[ch];
|
|
305
|
-
var glyphWidth = glyph.width;
|
|
306
|
-
var glyphHeight = glyph.height;
|
|
307
|
-
var kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
|
|
308
|
-
|
|
309
|
-
// draw it
|
|
310
|
-
if (glyphWidth !== 0 && glyphHeight !== 0) {
|
|
311
|
-
// some browser throw an exception when drawing a 0 width or height image
|
|
312
|
-
renderer.drawImage(this.fontImage,
|
|
313
|
-
glyph.x, glyph.y,
|
|
314
|
-
glyphWidth, glyphHeight,
|
|
315
|
-
x + glyph.xoffset,
|
|
316
|
-
y + glyph.yoffset * this.fontScale.y,
|
|
317
|
-
glyphWidth * this.fontScale.x, glyphHeight * this.fontScale.y
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
305
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
306
|
+
if (typeof glyph !== "undefined") {
|
|
307
|
+
var glyphWidth = glyph.width;
|
|
308
|
+
var glyphHeight = glyph.height;
|
|
309
|
+
var kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
|
|
310
|
+
var scaleX = this.fontScale.x;
|
|
311
|
+
var scaleY = this.fontScale.y;
|
|
312
|
+
|
|
313
|
+
// draw it
|
|
314
|
+
if (glyphWidth !== 0 && glyphHeight !== 0) {
|
|
315
|
+
// some browser throw an exception when drawing a 0 width or height image
|
|
316
|
+
renderer.drawImage(this.fontImage,
|
|
317
|
+
glyph.x, glyph.y,
|
|
318
|
+
glyphWidth, glyphHeight,
|
|
319
|
+
x + glyph.xoffset * scaleX,
|
|
320
|
+
y + glyph.yoffset * scaleY,
|
|
321
|
+
glyphWidth * scaleX, glyphHeight * scaleY
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// increment position
|
|
326
|
+
x += (glyph.xadvance + kerning) * scaleX;
|
|
327
|
+
lastGlyph = glyph;
|
|
328
|
+
} else {
|
|
329
|
+
console.warn("BitmapText: no defined Glyph in for " + String.fromCharCode(ch));
|
|
330
|
+
}
|
|
324
331
|
}
|
|
325
332
|
// increment line
|
|
326
333
|
y += stringHeight;
|
|
@@ -350,6 +357,5 @@ class BitmapText extends Renderable {
|
|
|
350
357
|
super.destroy();
|
|
351
358
|
}
|
|
352
359
|
|
|
353
|
-
}
|
|
354
|
-
|
|
360
|
+
}
|
|
355
361
|
export default BitmapText;
|
|
@@ -14,7 +14,7 @@ function getValueFromPair(string, pattern) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
return value[0].split("=")[1];
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Gets the first glyph in the map that is not a space character
|
|
@@ -32,7 +32,7 @@ function getFirstGlyph(glyphs) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return null;
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Creates a glyph to use for the space character
|
|
@@ -50,9 +50,7 @@ function createSpaceGlyph(glyphs) {
|
|
|
50
50
|
glyph.xadvance = getFirstGlyph(glyphs).xadvance;
|
|
51
51
|
glyphs[spaceCharCode] = glyph;
|
|
52
52
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
}
|
|
56
54
|
|
|
57
55
|
/**
|
|
58
56
|
* Class for storing relevant data from the font file.
|
|
@@ -188,6 +186,5 @@ class BitmapTextData {
|
|
|
188
186
|
}
|
|
189
187
|
this.capHeight -= padY;
|
|
190
188
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
189
|
+
}
|
|
193
190
|
export default BitmapTextData;
|
package/src/text/glyph.js
CHANGED
package/src/text/text.js
CHANGED
|
@@ -235,7 +235,7 @@ class Text extends Renderable {
|
|
|
235
235
|
*/
|
|
236
236
|
setFont(font, size = 10) {
|
|
237
237
|
// font name and type
|
|
238
|
-
var font_names = font.split(",").map(
|
|
238
|
+
var font_names = font.split(",").map((value) => {
|
|
239
239
|
value = value.trim();
|
|
240
240
|
return (
|
|
241
241
|
!/(^".*"$)|(^'.*'$)/.test(value)
|
|
@@ -440,6 +440,5 @@ class Text extends Renderable {
|
|
|
440
440
|
this._text.length = 0;
|
|
441
441
|
super.destroy();
|
|
442
442
|
}
|
|
443
|
-
}
|
|
444
|
-
|
|
443
|
+
}
|
|
445
444
|
export default Text;
|
package/src/text/textmetrics.js
CHANGED
|
@@ -56,9 +56,11 @@ class TextMetrics extends Bounds {
|
|
|
56
56
|
for (var i = 0; i < characters.length; i++) {
|
|
57
57
|
var ch = characters[i].charCodeAt(0);
|
|
58
58
|
var glyph = this.ancestor.fontData.glyphs[ch];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
if (typeof glyph !== "undefined") {
|
|
60
|
+
var kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
|
|
61
|
+
width += (glyph.xadvance + kerning) * this.ancestor.fontScale.x;
|
|
62
|
+
lastGlyph = glyph;
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
65
|
return width;
|
|
64
66
|
}
|
package/src/text/textstyle.js
CHANGED
package/src/tweens/tween.js
CHANGED
|
@@ -342,7 +342,7 @@ class Tween {
|
|
|
342
342
|
onComplete( onCompleteCallback ) {
|
|
343
343
|
this._onCompleteCallback = onCompleteCallback;
|
|
344
344
|
return this;
|
|
345
|
-
}
|
|
345
|
+
}
|
|
346
346
|
|
|
347
347
|
/** @ignore */
|
|
348
348
|
update( dt ) {
|
|
@@ -467,6 +467,5 @@ class Tween {
|
|
|
467
467
|
// export easing function as static class property
|
|
468
468
|
static get Easing() { return Easing; }
|
|
469
469
|
static get Interpolation() { return Interpolation; }
|
|
470
|
-
}
|
|
471
|
-
|
|
470
|
+
}
|
|
472
471
|
export default Tween;
|
package/src/utils/agent.js
CHANGED
|
@@ -29,12 +29,12 @@ export function prefixed(name, obj) {
|
|
|
29
29
|
var uc_name = capitalize(name);
|
|
30
30
|
|
|
31
31
|
var result;
|
|
32
|
-
vendors.some(
|
|
32
|
+
vendors.some((vendor) => {
|
|
33
33
|
var name = vendor + uc_name;
|
|
34
34
|
return (result = (name in obj) ? obj[name] : undefined);
|
|
35
35
|
});
|
|
36
36
|
return result;
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Set a vendor-prefixed property
|
|
@@ -55,7 +55,7 @@ export function setPrefixed(name, value, obj) {
|
|
|
55
55
|
|
|
56
56
|
var uc_name = capitalize(name);
|
|
57
57
|
|
|
58
|
-
vendors.some(
|
|
58
|
+
vendors.some((vendor) => {
|
|
59
59
|
var name = vendor + uc_name;
|
|
60
60
|
if (name in obj) {
|
|
61
61
|
obj[name] = value;
|
|
@@ -64,4 +64,4 @@ export function setPrefixed(name, value, obj) {
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
return false;
|
|
67
|
-
}
|
|
67
|
+
}
|
package/src/utils/array.js
CHANGED
|
@@ -23,7 +23,7 @@ export function remove(arr, obj) {
|
|
|
23
23
|
Array.prototype.splice.call(arr, i, 1);
|
|
24
24
|
}
|
|
25
25
|
return arr;
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* return a random array element
|
|
@@ -39,7 +39,7 @@ export function remove(arr, obj) {
|
|
|
39
39
|
*/
|
|
40
40
|
export function random(arr) {
|
|
41
41
|
return arr[mathRandom(0, arr.length)];
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* return a weighted random array element, favoring the earlier entries
|
|
@@ -51,4 +51,4 @@ export function random(arr) {
|
|
|
51
51
|
*/
|
|
52
52
|
export function weightedRandom(arr) {
|
|
53
53
|
return arr[mathWeightedRandom(0, arr.length)];
|
|
54
|
-
}
|
|
54
|
+
}
|
package/src/utils/file.js
CHANGED
|
@@ -19,7 +19,7 @@ const REMOVE_EXT = /\.[^\.]*$/;
|
|
|
19
19
|
*/
|
|
20
20
|
export function getBasename(path) {
|
|
21
21
|
return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* return the extension of the file in the given path
|
|
@@ -31,4 +31,4 @@ export function getBasename(path) {
|
|
|
31
31
|
*/
|
|
32
32
|
export function getExtension(path) {
|
|
33
33
|
return path.substring(path.lastIndexOf(".") + 1, path.length);
|
|
34
|
-
}
|
|
34
|
+
}
|
package/src/utils/function.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
export function defer(func, thisArg, ...args) {
|
|
22
22
|
return setTimeout(func.bind(thisArg), 0.01, ...args);
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* returns a function that, when invoked will only be triggered at most
|
|
@@ -47,7 +47,7 @@ export function throttle(fn, delay, no_trailing) {
|
|
|
47
47
|
if (no_trailing === false) {
|
|
48
48
|
// hold on to it
|
|
49
49
|
clearTimeout(deferTimer);
|
|
50
|
-
deferTimer = setTimeout(
|
|
50
|
+
deferTimer = setTimeout(() => {
|
|
51
51
|
last = now;
|
|
52
52
|
return fn.apply(null, args);
|
|
53
53
|
}, elasped);
|
|
@@ -58,4 +58,4 @@ export function throttle(fn, delay, no_trailing) {
|
|
|
58
58
|
return fn.apply(null, args);
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
}
|
|
61
|
+
}
|
package/src/utils/string.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export function capitalize(str) {
|
|
15
15
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* returns true if the given string contains a numeric integer or float value
|
|
@@ -28,7 +28,7 @@ export function isNumeric(str) {
|
|
|
28
28
|
str = str.trim();
|
|
29
29
|
}
|
|
30
30
|
return !isNaN(str) && /[+-]?([0-9]*[.])?[0-9]+/.test(str);
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* returns true if the given string contains a true or false
|
|
@@ -41,7 +41,7 @@ export function isNumeric(str) {
|
|
|
41
41
|
export function isBoolean(str) {
|
|
42
42
|
var trimmed = str.trim();
|
|
43
43
|
return (trimmed === "true") || (trimmed === "false");
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* convert a string to the corresponding hexadecimal value
|
|
@@ -57,7 +57,7 @@ export function toHex(str) {
|
|
|
57
57
|
res += str.charCodeAt(c++).toString(16);
|
|
58
58
|
}
|
|
59
59
|
return res;
|
|
60
|
-
}
|
|
60
|
+
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
|
|
@@ -70,4 +70,4 @@ export function toHex(str) {
|
|
|
70
70
|
*/
|
|
71
71
|
export function isDataUrl(str) {
|
|
72
72
|
return /^data:(.+);base64,(.+)$/.test(str);
|
|
73
|
-
}
|
|
73
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -124,9 +124,9 @@ var utils = {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// parse the url
|
|
127
|
-
url.slice(1).split("&").filter(
|
|
127
|
+
url.slice(1).split("&").filter((value) => {
|
|
128
128
|
return (value !== "");
|
|
129
|
-
}).forEach(
|
|
129
|
+
}).forEach((value) => {
|
|
130
130
|
var kv = value.split("=");
|
|
131
131
|
var k = kv.shift();
|
|
132
132
|
var v = kv.join("=");
|
package/src/video/renderer.js
CHANGED
|
@@ -70,7 +70,7 @@ class Renderer {
|
|
|
70
70
|
this.currentBlendMode = "none";
|
|
71
71
|
|
|
72
72
|
// create the main screen canvas
|
|
73
|
-
if (device.ejecta === true) {
|
|
73
|
+
if (device.platform.ejecta === true) {
|
|
74
74
|
// a main canvas is already automatically created by Ejecta
|
|
75
75
|
this.canvas = document.getElementById("canvas");
|
|
76
76
|
} else if (typeof globalThis.canvas !== "undefined") {
|
|
@@ -398,6 +398,5 @@ class Renderer {
|
|
|
398
398
|
*/
|
|
399
399
|
drawFont(/*bounds*/) {}
|
|
400
400
|
|
|
401
|
-
}
|
|
402
|
-
|
|
401
|
+
}
|
|
403
402
|
export default Renderer;
|
|
@@ -346,7 +346,7 @@ export class TextureAtlas {
|
|
|
346
346
|
region = this.getAtlas(atlas)[name];
|
|
347
347
|
} else {
|
|
348
348
|
// look for the given region in each existing atlas
|
|
349
|
-
this.atlases.forEach(
|
|
349
|
+
this.atlases.forEach((atlas) => {
|
|
350
350
|
if (typeof atlas[name] !== "undefined") {
|
|
351
351
|
// there should be only one
|
|
352
352
|
region = atlas[name];
|
|
@@ -507,4 +507,4 @@ export class TextureAtlas {
|
|
|
507
507
|
atlasIndices: indices
|
|
508
508
|
}, settings || {}));
|
|
509
509
|
}
|
|
510
|
-
}
|
|
510
|
+
}
|