melonjs 15.0.0 → 15.1.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 -4
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +7 -3
- package/dist/melonjs.mjs/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +27 -17
- package/dist/melonjs.mjs/application/header.js +6 -5
- package/dist/melonjs.mjs/application/resize.js +20 -20
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +17 -17
- package/dist/melonjs.mjs/camera/camera2d.js +10 -10
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +4 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
- package/dist/melonjs.mjs/geometries/line.js +9 -9
- package/dist/melonjs.mjs/geometries/path2d.js +53 -53
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +29 -29
- package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
- package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
- package/dist/melonjs.mjs/index.js +5 -5
- package/dist/melonjs.mjs/input/gamepad.js +30 -30
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +15 -15
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +58 -58
- package/dist/melonjs.mjs/lang/console.js +3 -3
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +9 -9
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +7 -7
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +13 -13
- package/dist/melonjs.mjs/loader/settings.js +3 -3
- package/dist/melonjs.mjs/math/color.js +21 -21
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +22 -22
- package/dist/melonjs.mjs/math/matrix3.js +52 -52
- package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
- package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
- package/dist/melonjs.mjs/math/vector2.js +11 -11
- package/dist/melonjs.mjs/math/vector3.js +21 -21
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +5 -5
- package/dist/melonjs.mjs/particles/particle.js +8 -8
- package/dist/melonjs.mjs/particles/settings.js +3 -3
- package/dist/melonjs.mjs/physics/body.js +17 -17
- package/dist/melonjs.mjs/physics/bounds.js +12 -12
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +14 -14
- package/dist/melonjs.mjs/physics/quadtree.js +19 -19
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +60 -60
- package/dist/melonjs.mjs/physics/world.js +4 -4
- package/dist/melonjs.mjs/plugin/plugin.js +11 -11
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +77 -59
- package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
- package/dist/melonjs.mjs/renderable/light2d.js +6 -6
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
- package/dist/melonjs.mjs/renderable/renderable.js +11 -11
- package/dist/melonjs.mjs/renderable/sprite.js +25 -25
- package/dist/melonjs.mjs/renderable/trigger.js +11 -9
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -63
- package/dist/melonjs.mjs/state/stage.js +7 -7
- package/dist/melonjs.mjs/state/state.js +15 -15
- package/dist/melonjs.mjs/system/device.js +2 -2
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +9 -9
- package/dist/melonjs.mjs/system/save.js +6 -6
- package/dist/melonjs.mjs/system/timer.js +16 -12
- package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
- package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
- package/dist/melonjs.mjs/text/glyph.js +3 -3
- package/dist/melonjs.mjs/text/text.js +10 -9
- package/dist/melonjs.mjs/text/textmetrics.js +15 -15
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +4 -4
- package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
- package/dist/melonjs.mjs/tweens/tween.js +11 -11
- package/dist/melonjs.mjs/utils/agent.js +6 -6
- package/dist/melonjs.mjs/utils/array.js +4 -4
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +5 -5
- package/dist/melonjs.mjs/utils/string.js +3 -3
- package/dist/melonjs.mjs/utils/utils.js +16 -16
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +35 -109
- package/dist/melonjs.mjs/video/renderer.js +74 -7
- package/dist/melonjs.mjs/video/texture/atlas.js +37 -37
- package/dist/melonjs.mjs/video/texture/cache.js +9 -10
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +2 -2
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +18 -15
- package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +55 -38
- package/dist/melonjs.module.js +1747 -1809
- package/dist/types/application/application.d.ts +11 -8
- package/dist/types/audio/audio.d.ts +3 -3
- package/dist/types/index.d.ts +4 -3
- package/dist/types/input/input.d.ts +1 -1
- package/dist/types/input/keyboard.d.ts +1 -1
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/level.d.ts +2 -2
- package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
- package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
- package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
- package/dist/types/loader/loader.d.ts +2 -2
- package/dist/types/loader/settings.d.ts +2 -2
- package/dist/types/particles/emitter.d.ts +1 -1
- package/dist/types/physics/collision.d.ts +1 -1
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/plugin/plugin.d.ts +2 -2
- package/dist/types/renderable/container.d.ts +21 -17
- package/dist/types/renderable/sprite.d.ts +11 -11
- package/dist/types/renderable/trigger.d.ts +1 -1
- package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
- package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
- package/dist/types/renderable/ui/uitextbutton.d.ts +52 -11
- package/dist/types/state/stage.d.ts +1 -1
- package/dist/types/system/device.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +3 -3
- package/dist/types/system/timer.d.ts +5 -5
- package/dist/types/text/bitmaptext.d.ts +1 -1
- package/dist/types/text/text.d.ts +1 -1
- package/dist/types/utils/array.d.ts +2 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +8 -76
- package/dist/types/video/renderer.d.ts +48 -0
- package/dist/types/video/texture/atlas.d.ts +3 -3
- package/dist/types/video/texture/canvas_texture.d.ts +40 -0
- package/dist/types/video/webgl/glshader.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +13 -9
- package/package.json +14 -14
- package/src/application/application.js +26 -16
- package/src/application/header.js +5 -4
- package/src/application/resize.js +19 -19
- package/src/audio/audio.js +16 -16
- package/src/camera/camera2d.js +9 -9
- package/src/entity/entity.js +3 -3
- package/src/geometries/ellipse.js +5 -5
- package/src/geometries/line.js +8 -8
- package/src/geometries/path2d.js +52 -52
- package/src/geometries/point.js +1 -1
- package/src/geometries/poly.js +28 -28
- package/src/geometries/rectangle.js +7 -7
- package/src/geometries/roundrect.js +5 -5
- package/src/index.js +3 -2
- package/src/input/gamepad.js +29 -29
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -14
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +52 -52
- package/src/lang/console.js +2 -2
- package/src/lang/deprecated.js +1 -1
- package/src/level/level.js +8 -8
- package/src/level/tiled/TMXGroup.js +2 -2
- package/src/level/tiled/TMXLayer.js +30 -30
- package/src/level/tiled/TMXObject.js +7 -7
- package/src/level/tiled/TMXTile.js +7 -7
- package/src/level/tiled/TMXTileMap.js +18 -18
- package/src/level/tiled/TMXTileset.js +14 -14
- package/src/level/tiled/TMXTilesetGroup.js +2 -2
- package/src/level/tiled/TMXUtils.js +45 -40
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
- package/src/loader/loader.js +6 -6
- package/src/loader/loadingscreen.js +1 -1
- package/src/loader/parser.js +12 -12
- package/src/loader/settings.js +2 -2
- package/src/math/color.js +20 -20
- package/src/math/math.js +1 -1
- package/src/math/matrix2.js +21 -21
- package/src/math/matrix3.js +51 -51
- package/src/math/observable_vector2.js +11 -11
- package/src/math/observable_vector3.js +21 -21
- package/src/math/vector2.js +10 -10
- package/src/math/vector3.js +20 -20
- package/src/particles/emitter.js +4 -4
- package/src/particles/particle.js +7 -7
- package/src/particles/settings.js +2 -2
- package/src/physics/body.js +16 -16
- package/src/physics/bounds.js +11 -11
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +18 -18
- package/src/physics/sat.js +59 -59
- package/src/physics/world.js +3 -3
- package/src/plugin/plugin.js +8 -8
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/container.js +76 -58
- package/src/renderable/dragndrop.js +4 -4
- package/src/renderable/imagelayer.js +6 -5
- package/src/renderable/light2d.js +5 -5
- package/src/renderable/nineslicesprite.js +11 -11
- package/src/renderable/renderable.js +10 -10
- package/src/renderable/sprite.js +24 -24
- package/src/renderable/trigger.js +10 -8
- package/src/renderable/ui/uibaseelement.js +96 -26
- package/src/renderable/ui/uispriteelement.js +24 -24
- package/src/renderable/ui/uitextbutton.js +85 -65
- package/src/state/stage.js +6 -6
- package/src/state/state.js +14 -14
- package/src/system/device.js +1 -1
- package/src/system/event.js +1 -1
- package/src/system/pooling.js +8 -8
- package/src/system/save.js +5 -5
- package/src/system/timer.js +15 -11
- package/src/text/bitmaptext.js +19 -19
- package/src/text/bitmaptextdata.js +21 -21
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +9 -8
- package/src/text/textmetrics.js +14 -14
- package/src/tweens/easing.js +3 -3
- package/src/tweens/interpolation.js +7 -7
- package/src/tweens/tween.js +10 -10
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +3 -3
- package/src/utils/function.js +4 -4
- package/src/utils/string.js +2 -2
- package/src/utils/utils.js +15 -15
- package/src/video/canvas/canvas_renderer.js +34 -108
- package/src/video/renderer.js +72 -5
- package/src/video/texture/atlas.js +36 -36
- package/src/video/texture/cache.js +6 -6
- package/src/video/texture/canvas_texture.js +62 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +4 -4
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +17 -14
- package/src/video/webgl/glshader.js +6 -6
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/program.js +6 -6
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_renderer.js +54 -37
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
6
6
|
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
|
|
7
7
|
*/
|
|
8
|
-
import Vector2d from '../../math/vector2.js';
|
|
9
8
|
import BitmapText from '../../text/bitmaptext.js';
|
|
10
9
|
import RoundRect from '../../geometries/roundrect.js';
|
|
11
10
|
import UIBaseElement from './uibaseelement.js';
|
|
@@ -17,25 +16,27 @@ import UIBaseElement from './uibaseelement.js';
|
|
|
17
16
|
*/
|
|
18
17
|
class UITextButton extends UIBaseElement {
|
|
19
18
|
/**
|
|
20
|
-
* A Text Button with an outlined background border, filled with background color.
|
|
19
|
+
* A Bitmap Text Button with an outlined background border, filled with background color.
|
|
21
20
|
* It uses a RoundRect as background and changes the background color on hovering over.
|
|
22
21
|
* The background will be drawn with 0.5 opacity, so that the background of the button is
|
|
23
22
|
* slightly shining through.
|
|
24
23
|
* @param {number} x - x pos of the button
|
|
25
24
|
* @param {number} y - y pos of the button
|
|
26
25
|
* @param {string} [settings.font] - The name of the BitmapText font to use
|
|
27
|
-
* @param {number} [settings.size] - The scale factor of the
|
|
28
|
-
* @param {string} [settings.text] - The text to display
|
|
26
|
+
* @param {number} [settings.size=1] - The scale factor of the BitmapText
|
|
27
|
+
* @param {string} [settings.text] - The text to display
|
|
29
28
|
* @param {string} [settings.bindKey] - The key to bind the action to (default: none)
|
|
30
|
-
* @param {string} [settings.backgroundColor] - The css value of a background color
|
|
31
|
-
* @param {string} [settings.hoverColor] - The css value of a color to be used if the pointer hovers over the button
|
|
32
|
-
* @param {string} [settings.borderStrokeColor] - The css value of a color to be used to draw the border
|
|
33
|
-
* @param {string} [settings.fillStyle] - The css value of a tint color to be used to tint the
|
|
29
|
+
* @param {string} [settings.backgroundColor="#00aa0080"] - The css value of a background color
|
|
30
|
+
* @param {string} [settings.hoverColor="#00ff00ff"] - The css value of a color to be used if the pointer hovers over the button
|
|
31
|
+
* @param {string} [settings.borderStrokeColor="#000000"] - The css value of a color to be used to draw the border
|
|
32
|
+
* @param {string} [settings.fillStyle] - The css value of a tint color to be used to tint the BitmapText
|
|
33
|
+
* @param {string} [settings.textAlign="center"] - horizontal text alignment
|
|
34
|
+
* @param {string} [settings.textBaseline="middle"] - the text baseline
|
|
34
35
|
* @param {number} [settings.borderWidth] - Width of the button
|
|
35
36
|
* @param {number} [settings.borderHeight] - Height of the button
|
|
36
37
|
* @example
|
|
37
38
|
* // Create a new Button
|
|
38
|
-
* class PlayButton extends
|
|
39
|
+
* class PlayButton extends UITextButton {
|
|
39
40
|
* constructor(x,y) {
|
|
40
41
|
* super(x,y, {
|
|
41
42
|
* font: 'my-font',
|
|
@@ -51,74 +52,93 @@ import UIBaseElement from './uibaseelement.js';
|
|
|
51
52
|
* }
|
|
52
53
|
* }
|
|
53
54
|
*
|
|
54
|
-
*
|
|
55
|
+
* world.addChild(new PlayButton(15,200));
|
|
55
56
|
*/
|
|
56
57
|
constructor(x, y, settings) {
|
|
57
58
|
super(x, y);
|
|
58
|
-
settings.font = settings.font || "24Outline";
|
|
59
|
-
settings.size = settings.size || 1;
|
|
60
|
-
settings.text = settings.text || "<Click Me>";
|
|
61
|
-
settings.bindKey = settings.bindKey || -1;
|
|
62
|
-
settings.backgroundColor = settings.backgroundColor || "#00aa00";
|
|
63
|
-
settings.hoverColor = settings.hoverColor || "#00ff00";
|
|
64
|
-
settings.borderStrokeColor = settings.borderStrokeColor || "#000000";
|
|
65
|
-
settings.fillStyle = settings.fillStyle || "#ffffff";
|
|
66
|
-
settings.lineWidth = settings.lineWidth || 1;
|
|
67
|
-
settings.anchorPoint = settings.anchorPoint || new Vector2d(0, 0);
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The key to bind the action to
|
|
62
|
+
* @type {string}
|
|
63
|
+
*/
|
|
64
|
+
this.bindKey = settings.bindKey || -1;
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
/**
|
|
67
|
+
* The css value of a background color
|
|
68
|
+
* @type {string}
|
|
69
|
+
*/
|
|
70
|
+
this.backgroundColor = settings.backgroundColor || "#00aa0080";
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The css value of a color to be used if the pointer hovers over the button
|
|
74
|
+
* @type {string}
|
|
75
|
+
*/
|
|
76
|
+
this.hoverColor = settings.hoverColor || "#00ff00ff";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The css value of a color to be used to draw the border
|
|
80
|
+
* @type {string}
|
|
81
|
+
*/
|
|
82
|
+
this.borderStrokeColor = settings.borderStrokeColor || "#000000";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Set the default text alignment (or justification),<br>
|
|
86
|
+
* possible values are "left", "right", and "center".
|
|
87
|
+
* @public
|
|
88
|
+
* @type {string}
|
|
89
|
+
* @default "center"
|
|
90
|
+
*/
|
|
91
|
+
this.textAlign = settings.textAlign = settings.textAlign || "center";
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Set the text baseline (e.g. the Y-coordinate for the draw operation), <br>
|
|
95
|
+
* possible values are "top", "hanging, "middle, "alphabetic, "ideographic, "bottom"<br>
|
|
96
|
+
* @public
|
|
97
|
+
* @type {string}
|
|
98
|
+
* @default "middle"
|
|
99
|
+
*/
|
|
100
|
+
this.textBaseline = settings.textBaseline = settings.textBaseline || "middle";
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* the bitmapText used by the UITextButton class
|
|
104
|
+
* @type {BitmapText}
|
|
105
|
+
*/
|
|
106
|
+
this.bitmapText = new BitmapText(0, 0, settings);
|
|
86
107
|
|
|
87
|
-
//
|
|
88
|
-
this.
|
|
89
|
-
this.dimensions
|
|
90
|
-
|
|
91
|
-
this.settings = settings;
|
|
108
|
+
// "detect" the button size
|
|
109
|
+
this.dimensions = this.bitmapText.measureText();
|
|
110
|
+
settings.borderWidth = settings.borderWidth || this.dimensions.width + 16;
|
|
111
|
+
settings.borderHeight = settings.borderHeight || this.dimensions.height + 16;
|
|
92
112
|
|
|
93
|
-
//
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
// create the round rect button
|
|
114
|
+
this.border = new RoundRect(x, y, settings.borderWidth, settings.borderHeight);
|
|
115
|
+
|
|
116
|
+
// resize the container accordingly
|
|
117
|
+
this.resize(
|
|
118
|
+
this.border.getBounds().width,
|
|
119
|
+
this.border.getBounds().height
|
|
98
120
|
);
|
|
121
|
+
|
|
122
|
+
// adjust size position
|
|
123
|
+
this.bitmapText.pos.set(this.width / 2, this.height / 2);
|
|
124
|
+
|
|
125
|
+
// add bitmapText to the UI container
|
|
126
|
+
this.addChild(this.bitmapText);
|
|
99
127
|
}
|
|
100
128
|
|
|
101
129
|
draw(renderer) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
renderer.setColor(this.settings.backgroundColor);
|
|
130
|
+
if (this.hover === true) {
|
|
131
|
+
renderer.setColor(this.hoverColor);
|
|
105
132
|
} else {
|
|
106
|
-
renderer.setColor(this.
|
|
133
|
+
renderer.setColor(this.backgroundColor);
|
|
107
134
|
}
|
|
108
|
-
|
|
109
135
|
renderer.fill(this.border);
|
|
110
|
-
renderer.
|
|
111
|
-
renderer.setColor(this.settings.borderStrokeColor);
|
|
136
|
+
renderer.setColor(this.borderStrokeColor);
|
|
112
137
|
renderer.stroke(this.border);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
renderer,
|
|
118
|
-
this.settings.text,
|
|
119
|
-
this.font.pos.x,
|
|
120
|
-
this.font.pos.y
|
|
121
|
-
);
|
|
138
|
+
this.bitmapText.preDraw(renderer);
|
|
139
|
+
this.bitmapText.draw(renderer);
|
|
140
|
+
this.bitmapText.postDraw(renderer);
|
|
141
|
+
super.draw(renderer);
|
|
122
142
|
}
|
|
123
143
|
}
|
|
124
144
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -11,10 +11,10 @@ import Camera2d from '../camera/camera2d.js';
|
|
|
11
11
|
import Color from '../math/color.js';
|
|
12
12
|
|
|
13
13
|
// a default camera instance to use across all stages
|
|
14
|
-
|
|
14
|
+
let default_camera;
|
|
15
15
|
|
|
16
16
|
// default stage settings
|
|
17
|
-
|
|
17
|
+
let default_settings = {
|
|
18
18
|
cameras : []
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -56,7 +56,7 @@ var default_settings = {
|
|
|
56
56
|
* @see Stage.ambientLight
|
|
57
57
|
* @example
|
|
58
58
|
* // create a white spot light
|
|
59
|
-
*
|
|
59
|
+
* let whiteLight = new me.Light2d(0, 0, 140, "#fff", 0.7);
|
|
60
60
|
* // and add the light to this current stage
|
|
61
61
|
* this.lights.set("whiteLight", whiteLight);
|
|
62
62
|
* // set a dark ambient light
|
|
@@ -103,8 +103,8 @@ var default_settings = {
|
|
|
103
103
|
// empty or no default camera
|
|
104
104
|
if (this.cameras.has("default") === false) {
|
|
105
105
|
if (typeof default_camera === "undefined") {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let width = renderer.getWidth();
|
|
107
|
+
let height = renderer.getHeight();
|
|
108
108
|
// new default camera instance
|
|
109
109
|
default_camera = new Camera2d(0, 0, width, height);
|
|
110
110
|
}
|
|
@@ -128,7 +128,7 @@ var default_settings = {
|
|
|
128
128
|
*/
|
|
129
129
|
update(dt) {
|
|
130
130
|
// update all objects (and pass the elapsed time since last frame)
|
|
131
|
-
|
|
131
|
+
let isDirty = game.world.update(dt);
|
|
132
132
|
|
|
133
133
|
// update the camera/viewport
|
|
134
134
|
// iterate through all cameras
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -14,32 +14,32 @@ import Stage from './stage.js';
|
|
|
14
14
|
import DefaultLoadingScreen from '../loader/loadingscreen.js';
|
|
15
15
|
|
|
16
16
|
// current state
|
|
17
|
-
|
|
17
|
+
let _state = -1;
|
|
18
18
|
|
|
19
19
|
// requestAnimeFrame Id
|
|
20
|
-
|
|
20
|
+
let _animFrameId = -1;
|
|
21
21
|
|
|
22
22
|
// whether the game state is "paused"
|
|
23
|
-
|
|
23
|
+
let _isPaused = false;
|
|
24
24
|
|
|
25
25
|
// list of stages
|
|
26
|
-
|
|
26
|
+
let _stages = {};
|
|
27
27
|
|
|
28
28
|
// fading transition parameters between screen
|
|
29
|
-
|
|
29
|
+
let _fade = {
|
|
30
30
|
color : "",
|
|
31
31
|
duration : 0
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
// callback when state switch is done
|
|
35
35
|
/** @ignore */
|
|
36
|
-
|
|
36
|
+
let _onSwitchComplete = null;
|
|
37
37
|
|
|
38
38
|
// just to keep track of possible extra arguments
|
|
39
|
-
|
|
39
|
+
let _extraArgs = null;
|
|
40
40
|
|
|
41
41
|
// store the elapsed time during pause/stop period
|
|
42
|
-
|
|
42
|
+
let _pauseTime = 0;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* @ignore
|
|
@@ -78,7 +78,7 @@ function _pauseRunLoop() {
|
|
|
78
78
|
* @ignore
|
|
79
79
|
*/
|
|
80
80
|
function _renderFrame(time) {
|
|
81
|
-
|
|
81
|
+
let stage = _stages[_state].stage;
|
|
82
82
|
// update all game objects
|
|
83
83
|
game.update(time, stage);
|
|
84
84
|
// render all game objects
|
|
@@ -189,7 +189,7 @@ on(BOOT, () => {
|
|
|
189
189
|
* a State Manager (state machine)
|
|
190
190
|
* @namespace state
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
let state = {
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
195
|
* default state ID for Loading Stage
|
|
@@ -278,10 +278,10 @@ var state = {
|
|
|
278
278
|
* @name USER
|
|
279
279
|
* @memberof state
|
|
280
280
|
* @example
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
281
|
+
* let STATE_INFO = me.state.USER + 0;
|
|
282
|
+
* let STATE_WARN = me.state.USER + 1;
|
|
283
|
+
* let STATE_ERROR = me.state.USER + 2;
|
|
284
|
+
* let STATE_CUTSCENE = me.state.USER + 3;
|
|
285
285
|
*/
|
|
286
286
|
USER : 100,
|
|
287
287
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -399,7 +399,7 @@ let stopOnBlur = false;
|
|
|
399
399
|
* @param {Function} fn - the function to be executed
|
|
400
400
|
* @example
|
|
401
401
|
* // small game skeleton
|
|
402
|
-
*
|
|
402
|
+
* let game = {
|
|
403
403
|
* // called by the me.device.onReady function
|
|
404
404
|
* onload = function () {
|
|
405
405
|
* // init video
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -13,7 +13,7 @@ import EventEmitter from '../node_modules/eventemitter3/index.js';
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
// internal instance of the event emiter
|
|
16
|
-
|
|
16
|
+
let eventEmitter = new EventEmitter();
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* event when the DOM is Ready is booting
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -65,11 +65,11 @@ class ObjectPool {
|
|
|
65
65
|
* me.pool.register("enemy", EnemyEntity, true);
|
|
66
66
|
* // ...
|
|
67
67
|
* // when we need to manually create a new bullet:
|
|
68
|
-
*
|
|
68
|
+
* let bullet = me.pool.pull("bullet", x, y, direction);
|
|
69
69
|
* // ...
|
|
70
70
|
* // params aren't a fixed number
|
|
71
71
|
* // when we need new enemy we can add more params, that the object construct requires:
|
|
72
|
-
*
|
|
72
|
+
* let enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
|
|
73
73
|
* // ...
|
|
74
74
|
* // when we want to destroy existing object, the remove
|
|
75
75
|
* // function will ensure the object can then be reallocated later
|
|
@@ -77,9 +77,9 @@ class ObjectPool {
|
|
|
77
77
|
* me.game.world.removeChild(bullet);
|
|
78
78
|
*/
|
|
79
79
|
pull(name, ...args) {
|
|
80
|
-
|
|
80
|
+
let className = this.objectClass[name];
|
|
81
81
|
if (className) {
|
|
82
|
-
|
|
82
|
+
let proto = className["class"],
|
|
83
83
|
poolArray = className.pool,
|
|
84
84
|
obj;
|
|
85
85
|
|
|
@@ -105,7 +105,7 @@ class ObjectPool {
|
|
|
105
105
|
* note: this will trigger the garbage collector
|
|
106
106
|
*/
|
|
107
107
|
purge() {
|
|
108
|
-
for (
|
|
108
|
+
for (let className in this.objectClass) {
|
|
109
109
|
if (this.objectClass[className]) {
|
|
110
110
|
this.objectClass[className].pool = [];
|
|
111
111
|
}
|
|
@@ -160,7 +160,7 @@ class ObjectPool {
|
|
|
160
160
|
* }
|
|
161
161
|
*/
|
|
162
162
|
poolable(obj) {
|
|
163
|
-
|
|
163
|
+
let className = obj.className;
|
|
164
164
|
return (typeof className !== "undefined") &&
|
|
165
165
|
(typeof obj.onResetEvent === "function") &&
|
|
166
166
|
(className in this.objectClass) &&
|
|
@@ -177,7 +177,7 @@ class ObjectPool {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
let pool = new ObjectPool();
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
183
|
* a default global ObjectPool instance
|
|
@@ -188,7 +188,7 @@ var pool = new ObjectPool();
|
|
|
188
188
|
* pool.register("bullet", BulletEntity, true);
|
|
189
189
|
* // ...
|
|
190
190
|
* // when we need to manually create a new bullet:
|
|
191
|
-
*
|
|
191
|
+
* let bullet = pool.pull("bullet", x, y, direction, velocity);
|
|
192
192
|
* // ...
|
|
193
193
|
* // when we want to destroy existing object, the remove
|
|
194
194
|
* // function will ensure the object can then be reallocated later
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -39,7 +39,7 @@ import { on, BOOT } from './event.js';
|
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
// Variable to hold the object data
|
|
42
|
-
|
|
42
|
+
let data = {};
|
|
43
43
|
|
|
44
44
|
let hasLocalStorage = false;
|
|
45
45
|
|
|
@@ -64,10 +64,10 @@ function isReserved(key) {
|
|
|
64
64
|
on(BOOT, () => {
|
|
65
65
|
// Load previous data if local Storage is supported
|
|
66
66
|
if (hasLocalStorage === true) {
|
|
67
|
-
|
|
67
|
+
let me_save_content = globalThis.localStorage.getItem("me.save");
|
|
68
68
|
|
|
69
69
|
if (typeof me_save_content === "string" && me_save_content.length > 0) {
|
|
70
|
-
|
|
70
|
+
let keys = JSON.parse(me_save_content) || [];
|
|
71
71
|
keys.forEach((key) => {
|
|
72
72
|
data[key] = JSON.parse(globalThis.localStorage.getItem("me.save." + key));
|
|
73
73
|
});
|
|
@@ -75,7 +75,7 @@ on(BOOT, () => {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
let save = {
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Add new keys to localStorage and set them to the given default values if they do not exist
|
|
@@ -89,7 +89,7 @@ var save = {
|
|
|
89
89
|
* me.save.score = 1000;
|
|
90
90
|
*/
|
|
91
91
|
add(props) {
|
|
92
|
-
|
|
92
|
+
let obj = save;
|
|
93
93
|
|
|
94
94
|
Object.keys(props).forEach((key) => {
|
|
95
95
|
if (isReserved(key)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -78,7 +78,7 @@ class Timer {
|
|
|
78
78
|
this.reset();
|
|
79
79
|
this.now = this.last = 0;
|
|
80
80
|
// register to the game before update event
|
|
81
|
-
on(GAME_BEFORE_UPDATE, this.update
|
|
81
|
+
on(GAME_BEFORE_UPDATE, (time) => this.update(time));
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
// reset timer
|
|
@@ -116,7 +116,7 @@ class Timer {
|
|
|
116
116
|
* @param {number} delay - the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
117
117
|
* @param {boolean} [pauseable=true] - respects the pause state of the engine.
|
|
118
118
|
* @param {...*} args - optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
119
|
-
* @returns {number}
|
|
119
|
+
* @returns {number} a positive integer value which identifies the timer created by the call to setTimeout(), which can be used later with me.timer.clearTimeout().
|
|
120
120
|
* @example
|
|
121
121
|
* // set a timer to call "myFunction" after 1000ms
|
|
122
122
|
* me.timer.setTimeout(myFunction, 1000);
|
|
@@ -142,7 +142,7 @@ class Timer {
|
|
|
142
142
|
* @param {number} delay - the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
143
143
|
* @param {boolean} [pauseable=true] - respects the pause state of the engine.
|
|
144
144
|
* @param {...*} args - optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
145
|
-
* @returns {number}
|
|
145
|
+
* @returns {number} a numeric, non-zero value which identifies the timer created by the call to setInterval(), which can be used later with me.timer.clearInterval().
|
|
146
146
|
* @example
|
|
147
147
|
* // set a timer to call "myFunction" every 1000ms
|
|
148
148
|
* me.timer.setInterval(myFunction, 1000);
|
|
@@ -163,19 +163,23 @@ class Timer {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param {number} timeoutID - ID of the timeout to be
|
|
166
|
+
* Cancels a timeout previously established by calling setTimeout().
|
|
167
|
+
* @param {number} timeoutID - ID of the timeout to be cancelled
|
|
168
168
|
*/
|
|
169
169
|
clearTimeout(timeoutID) {
|
|
170
|
-
|
|
170
|
+
if (timeoutID > 0) {
|
|
171
|
+
utils.function.defer(this.clearTimer.bind(this), this, timeoutID);
|
|
172
|
+
}
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
/**
|
|
174
|
-
*
|
|
176
|
+
* cancels the timed, repeating action which was previously established by a call to setInterval().
|
|
175
177
|
* @param {number} intervalID - ID of the interval to be cleared
|
|
176
178
|
*/
|
|
177
179
|
clearInterval(intervalID) {
|
|
178
|
-
|
|
180
|
+
if (intervalID > 0) {
|
|
181
|
+
utils.function.defer(this.clearTimer.bind(this), this, intervalID);
|
|
182
|
+
}
|
|
179
183
|
}
|
|
180
184
|
|
|
181
185
|
/**
|
|
@@ -234,7 +238,7 @@ class Timer {
|
|
|
234
238
|
* @ignore
|
|
235
239
|
*/
|
|
236
240
|
clearTimer(timerId) {
|
|
237
|
-
for (
|
|
241
|
+
for (let i = 0, len = this.timers.length; i < len; i++) {
|
|
238
242
|
if (this.timers[i].timerId === timerId) {
|
|
239
243
|
this.timers.splice(i, 1);
|
|
240
244
|
break;
|
|
@@ -248,8 +252,8 @@ class Timer {
|
|
|
248
252
|
* @ignore
|
|
249
253
|
*/
|
|
250
254
|
updateTimers() {
|
|
251
|
-
for (
|
|
252
|
-
|
|
255
|
+
for (let i = 0, len = this.timers.length; i < len; i++) {
|
|
256
|
+
let _timer = this.timers[i];
|
|
253
257
|
if (!(_timer.pauseable && state.isPaused())) {
|
|
254
258
|
_timer.elapsed += this.delta;
|
|
255
259
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -39,7 +39,7 @@ import TextMetrics from './textmetrics.js';
|
|
|
39
39
|
* { name: "arial", type: "image" src: "data/font/arial.png" },
|
|
40
40
|
* ])
|
|
41
41
|
* // Then create an instance of your bitmap font:
|
|
42
|
-
*
|
|
42
|
+
* let myFont = new me.BitmapText(x, y, {font:"arial", text:"Hello"});
|
|
43
43
|
* // two possibilities for using "myFont"
|
|
44
44
|
* // either call the draw function from your Renderable draw function
|
|
45
45
|
* myFont.draw(renderer, "Hello!", 0, 0);
|
|
@@ -194,12 +194,12 @@ import TextMetrics from './textmetrics.js';
|
|
|
194
194
|
* @returns {Bounds} this Bitmap Text bounding box Rectangle object
|
|
195
195
|
*/
|
|
196
196
|
updateBounds(absolute = true) {
|
|
197
|
-
|
|
197
|
+
let bounds = this.getBounds();
|
|
198
198
|
|
|
199
199
|
bounds.clear();
|
|
200
200
|
|
|
201
201
|
if (typeof this.metrics !== "undefined") {
|
|
202
|
-
|
|
202
|
+
let ax, ay;
|
|
203
203
|
|
|
204
204
|
bounds.addBounds(this.metrics.measureText(this._text));
|
|
205
205
|
|
|
@@ -298,7 +298,7 @@ import TextMetrics from './textmetrics.js';
|
|
|
298
298
|
*/
|
|
299
299
|
draw(renderer, text, x, y) {
|
|
300
300
|
// save the previous global alpha value
|
|
301
|
-
|
|
301
|
+
let _alpha = renderer.globalAlpha();
|
|
302
302
|
|
|
303
303
|
// allows to provide backward compatibility when
|
|
304
304
|
// adding Bitmap Font to an object container
|
|
@@ -312,15 +312,15 @@ import TextMetrics from './textmetrics.js';
|
|
|
312
312
|
y = this.pos.y;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
let lX = x;
|
|
316
|
+
let stringHeight = this.metrics.lineHeight();
|
|
317
|
+
let maxWidth = 0;
|
|
318
318
|
|
|
319
|
-
for (
|
|
319
|
+
for (let i = 0; i < this._text.length; i++) {
|
|
320
320
|
x = lX;
|
|
321
|
-
|
|
321
|
+
let string = this._text[i].trimEnd();
|
|
322
322
|
// adjust x pos based on alignment value
|
|
323
|
-
|
|
323
|
+
let stringWidth = this.metrics.lineWidth(string);
|
|
324
324
|
switch (this.textAlign) {
|
|
325
325
|
case "right":
|
|
326
326
|
x -= stringWidth;
|
|
@@ -356,18 +356,18 @@ import TextMetrics from './textmetrics.js';
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// draw the string
|
|
359
|
-
|
|
360
|
-
for (
|
|
359
|
+
let lastGlyph = null;
|
|
360
|
+
for (let c = 0, len = string.length; c < len; c++) {
|
|
361
361
|
// calculate the char index
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
let ch = string.charCodeAt(c);
|
|
363
|
+
let glyph = this.fontData.glyphs[ch];
|
|
364
364
|
|
|
365
365
|
if (typeof glyph !== "undefined") {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
366
|
+
let glyphWidth = glyph.width;
|
|
367
|
+
let glyphHeight = glyph.height;
|
|
368
|
+
let kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
|
|
369
|
+
let scaleX = this.fontScale.x;
|
|
370
|
+
let scaleY = this.fontScale.y;
|
|
371
371
|
|
|
372
372
|
// draw it
|
|
373
373
|
if (glyphWidth !== 0 && glyphHeight !== 0) {
|