melonjs 15.2.1 → 15.4.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 +1 -1
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.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 +1 -1
- package/dist/melonjs.mjs/application/application.js +75 -23
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +13 -11
- package/dist/melonjs.mjs/application/settings.js +37 -1
- package/dist/melonjs.mjs/audio/audio.js +4 -6
- package/dist/melonjs.mjs/camera/camera2d.js +12 -14
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
- package/dist/melonjs.mjs/geometries/line.js +18 -25
- package/dist/melonjs.mjs/geometries/path2d.js +16 -13
- package/dist/melonjs.mjs/geometries/point.js +8 -16
- package/dist/melonjs.mjs/geometries/poly.js +40 -97
- package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
- package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
- package/dist/melonjs.mjs/index.js +6 -6
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +3 -3
- package/dist/melonjs.mjs/input/pointer.js +4 -4
- package/dist/melonjs.mjs/input/pointerevent.js +6 -7
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -47
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- 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 +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +4 -5
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +5 -5
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +5 -59
- package/dist/melonjs.mjs/math/matrix3.js +82 -141
- package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
- package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
- package/dist/melonjs.mjs/math/vector2.js +7 -91
- package/dist/melonjs.mjs/math/vector3.js +6 -90
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
- 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 +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +22 -20
- package/dist/melonjs.mjs/physics/bounds.js +27 -33
- package/dist/melonjs.mjs/physics/collision.js +5 -5
- package/dist/melonjs.mjs/physics/detector.js +10 -10
- package/dist/melonjs.mjs/physics/quadtree.js +5 -5
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +3 -4
- package/dist/melonjs.mjs/physics/world.js +6 -9
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
- package/dist/melonjs.mjs/renderable/container.js +25 -25
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
- package/dist/melonjs.mjs/renderable/light2d.js +3 -3
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +31 -39
- package/dist/melonjs.mjs/renderable/sprite.js +3 -3
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
- package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
- package/dist/melonjs.mjs/renderable/text/text.js +422 -0
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
- package/dist/melonjs.mjs/renderable/trigger.js +10 -10
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
- package/dist/melonjs.mjs/state/stage.js +13 -14
- package/dist/melonjs.mjs/state/state.js +4 -51
- package/dist/melonjs.mjs/system/device.js +51 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +46 -2
- package/dist/melonjs.mjs/system/platform.js +18 -18
- package/dist/melonjs.mjs/system/pooling.js +10 -10
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +2 -2
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +2 -3
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +5 -18
- package/dist/melonjs.mjs/video/renderer.js +17 -30
- package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +5 -29
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
- 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 +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +62 -67
- package/dist/melonjs.module.js +1272 -1713
- package/dist/types/application/application.d.ts +32 -31
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +80 -16
- package/dist/types/audio/audio.d.ts +4 -6
- package/dist/types/camera/camera2d.d.ts +13 -16
- package/dist/types/entity/entity.d.ts +0 -1
- package/dist/types/geometries/ellipse.d.ts +18 -50
- package/dist/types/geometries/path2d.d.ts +1 -1
- package/dist/types/geometries/point.d.ts +5 -13
- package/dist/types/geometries/poly.d.ts +26 -75
- package/dist/types/geometries/rectangle.d.ts +12 -58
- package/dist/types/geometries/roundrect.d.ts +2 -11
- package/dist/types/index.d.ts +3 -3
- package/dist/types/input/gamepad.d.ts +31 -31
- package/dist/types/input/keyboard.d.ts +105 -105
- package/dist/types/input/pointer.d.ts +21 -21
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
- package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
- package/dist/types/math/matrix2.d.ts +9 -63
- package/dist/types/math/matrix3.d.ts +9 -68
- package/dist/types/math/observable_vector2.d.ts +2 -2
- package/dist/types/math/observable_vector3.d.ts +2 -2
- package/dist/types/math/vector2.d.ts +8 -92
- package/dist/types/math/vector3.d.ts +8 -92
- package/dist/types/particles/settings.d.ts +29 -29
- package/dist/types/physics/body.d.ts +10 -8
- package/dist/types/physics/bounds.d.ts +24 -30
- package/dist/types/physics/collision.d.ts +12 -12
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/physics/world.d.ts +4 -7
- package/dist/types/renderable/container.d.ts +19 -19
- package/dist/types/renderable/imagelayer.d.ts +6 -6
- package/dist/types/renderable/light2d.d.ts +7 -7
- package/dist/types/renderable/renderable.d.ts +10 -18
- package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
- package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/renderable/text/glyph.d.ts +28 -0
- package/dist/types/renderable/text/text.d.ts +159 -0
- package/dist/types/renderable/text/textmetrics.d.ts +47 -0
- package/dist/types/renderable/text/textstyle.d.ts +5 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
- package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
- package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
- package/dist/types/state/stage.d.ts +3 -2
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +16 -9
- package/dist/types/system/event.d.ts +40 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +16 -43
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +4 -38
- package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
- package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
- package/dist/types/video/webgl/utils/precision.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +48 -84
- package/package.json +15 -15
- package/src/application/application.js +73 -21
- package/src/application/header.js +1 -1
- package/src/application/resize.js +11 -9
- package/src/application/settings.js +36 -0
- package/src/audio/audio.js +3 -5
- package/src/camera/camera2d.js +11 -13
- package/src/entity/entity.js +2 -3
- package/src/geometries/ellipse.js +25 -58
- package/src/geometries/line.js +17 -24
- package/src/geometries/path2d.js +15 -12
- package/src/geometries/point.js +7 -15
- package/src/geometries/poly.js +39 -96
- package/src/geometries/rectangle.js +36 -90
- package/src/geometries/roundrect.js +25 -34
- package/src/index.js +4 -4
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +3 -3
- package/src/input/pointerevent.js +5 -6
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +15 -32
- package/src/level/tiled/TMXObject.js +2 -3
- package/src/level/tiled/TMXTile.js +3 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXTileset.js +3 -6
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +36 -46
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- 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/parser.js +3 -4
- package/src/math/color.js +4 -4
- package/src/math/matrix2.js +4 -58
- package/src/math/matrix3.js +81 -140
- package/src/math/observable_vector2.js +6 -6
- package/src/math/observable_vector3.js +4 -4
- package/src/math/vector2.js +6 -90
- package/src/math/vector3.js +5 -89
- package/src/particles/emitter.js +1 -1
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +21 -19
- package/src/physics/bounds.js +26 -32
- package/src/physics/collision.js +4 -4
- package/src/physics/detector.js +9 -9
- package/src/physics/quadtree.js +4 -4
- package/src/physics/sat.js +2 -3
- package/src/physics/world.js +5 -8
- package/src/polyfill/roundrect.js +163 -163
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +3 -3
- package/src/renderable/container.js +24 -24
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +2 -2
- package/src/renderable/nineslicesprite.js +1 -1
- package/src/renderable/renderable.js +30 -38
- package/src/renderable/sprite.js +2 -2
- package/src/{text → renderable/text}/bitmaptext.js +8 -8
- package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
- package/src/{text → renderable/text}/glyph.js +1 -1
- package/src/{text → renderable/text}/text.js +16 -17
- package/src/{text → renderable/text}/textmetrics.js +2 -2
- package/src/renderable/trigger.js +9 -9
- package/src/renderable/ui/uibaseelement.js +6 -6
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +2 -2
- package/src/state/stage.js +12 -13
- package/src/state/state.js +2 -61
- package/src/system/device.js +50 -9
- package/src/system/event.js +44 -0
- package/src/system/platform.js +18 -18
- package/src/system/pooling.js +9 -9
- package/src/tweens/tween.js +1 -1
- package/src/utils/function.js +1 -2
- package/src/video/canvas/canvas_renderer.js +4 -17
- package/src/video/renderer.js +16 -29
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +7 -28
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +12 -13
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +1 -2
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/utils/precision.js +3 -3
- package/src/video/webgl/webgl_renderer.js +61 -66
- /package/src/{text → renderable/text}/textstyle.js +0 -0
|
@@ -49,8 +49,8 @@ function createGradient(light) {
|
|
|
49
49
|
* (multiple lights are not supported, alpha component of the ambient light is ignored)
|
|
50
50
|
* @see stage.lights
|
|
51
51
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
export default class Light2d extends Renderable {
|
|
53
|
+
/**
|
|
54
54
|
* @param {number} x - The horizontal position of the light.
|
|
55
55
|
* @param {number} y - The vertical position of the light.
|
|
56
56
|
* @param {number} radiusX - The horizontal radius of the light.
|
|
@@ -8,7 +8,7 @@ import Sprite from "./sprite.js";
|
|
|
8
8
|
* @see https://en.wikipedia.org/wiki/9-slice_scaling
|
|
9
9
|
* @augments Sprite
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default class NineSliceSprite extends Sprite {
|
|
12
12
|
/**
|
|
13
13
|
* @param {number} x - the x coordinates of the sprite object
|
|
14
14
|
* @param {number} y - the y coordinates of the sprite object
|
|
@@ -4,14 +4,13 @@ import Rect from "./../geometries/rectangle.js";
|
|
|
4
4
|
import pool from "./../system/pooling.js";
|
|
5
5
|
import { releaseAllPointerEvents } from "./../input/input.js";
|
|
6
6
|
import { clamp } from "./../math/math.js";
|
|
7
|
-
import Color from "./../math/color.js";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @classdesc
|
|
11
10
|
* A base class for renderable objects.
|
|
12
11
|
* @augments Rect
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
export default class Renderable extends Rect {
|
|
15
14
|
/**
|
|
16
15
|
* @param {number} x - position of the renderable object (accessible through inherited pos.x property)
|
|
17
16
|
* @param {number} y - position of the renderable object (accessible through inherited pos.y property)
|
|
@@ -97,7 +96,7 @@ import Color from "./../math/color.js";
|
|
|
97
96
|
*/
|
|
98
97
|
this.body = undefined;
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
/**
|
|
101
100
|
* (G)ame (U)nique (Id)entifier" <br>
|
|
102
101
|
* a GUID will be allocated for any renderable object added <br>
|
|
103
102
|
* to an object container (including the `me.game.world` container)
|
|
@@ -258,6 +257,9 @@ import Color from "./../math/color.js";
|
|
|
258
257
|
// viewport flag
|
|
259
258
|
this._inViewport = false;
|
|
260
259
|
|
|
260
|
+
// renderable cache tint value used by the getter/setter
|
|
261
|
+
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
262
|
+
|
|
261
263
|
// ensure it's fully opaque by default
|
|
262
264
|
this.setOpacity(1.0);
|
|
263
265
|
}
|
|
@@ -282,21 +284,11 @@ import Color from "./../math/color.js";
|
|
|
282
284
|
* this.tint.setColor(255, 255, 255);
|
|
283
285
|
*/
|
|
284
286
|
get tint() {
|
|
285
|
-
if (typeof this._tint === "undefined") {
|
|
286
|
-
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
287
|
-
}
|
|
288
287
|
return this._tint;
|
|
289
288
|
}
|
|
290
289
|
set tint(value) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
if (value instanceof Color) {
|
|
295
|
-
this._tint.copy(value);
|
|
296
|
-
} else {
|
|
297
|
-
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
298
|
-
this._tint.parseCSS(value);
|
|
299
|
-
}
|
|
290
|
+
this._tint.copy(value);
|
|
291
|
+
this.isDirty = true;
|
|
300
292
|
}
|
|
301
293
|
|
|
302
294
|
/**
|
|
@@ -577,7 +569,7 @@ import Color from "./../math/color.js";
|
|
|
577
569
|
}
|
|
578
570
|
|
|
579
571
|
if (absolute === true) {
|
|
580
|
-
|
|
572
|
+
let absPos = this.getAbsolutePosition();
|
|
581
573
|
bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
|
|
582
574
|
}
|
|
583
575
|
return bounds;
|
|
@@ -593,25 +585,25 @@ import Color from "./../math/color.js";
|
|
|
593
585
|
* update the renderable's bounding rect (private)
|
|
594
586
|
* @ignore
|
|
595
587
|
*/
|
|
596
|
-
|
|
588
|
+
updateBoundsPos(newX = this.pos.x, newY = this.pos.y) {
|
|
597
589
|
this.getBounds().translate(newX - this.pos.x, newY - this.pos.y);
|
|
598
|
-
|
|
590
|
+
}
|
|
599
591
|
|
|
600
|
-
|
|
592
|
+
/**
|
|
601
593
|
* return the renderable absolute position in the game world
|
|
602
594
|
* @returns {Vector2d}
|
|
603
595
|
*/
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
596
|
+
getAbsolutePosition() {
|
|
597
|
+
if (typeof this._absPos === "undefined") {
|
|
598
|
+
this._absPos = pool.pull("Vector2d");
|
|
599
|
+
}
|
|
600
|
+
// XXX Cache me or something
|
|
601
|
+
this._absPos.set(this.pos.x, this.pos.y);
|
|
602
|
+
if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
|
|
603
|
+
this._absPos.add(this.ancestor.getAbsolutePosition());
|
|
604
|
+
}
|
|
605
|
+
return this._absPos;
|
|
606
|
+
}
|
|
615
607
|
|
|
616
608
|
/**
|
|
617
609
|
* called when the anchor point value is changed
|
|
@@ -619,14 +611,14 @@ import Color from "./../math/color.js";
|
|
|
619
611
|
* @param {number} x - the new X value to be set for the anchor
|
|
620
612
|
* @param {number} y - the new Y value to be set for the anchor
|
|
621
613
|
*/
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
614
|
+
onAnchorUpdate(x, y) {
|
|
615
|
+
// since the callback is called before setting the new value
|
|
616
|
+
// manually update the anchor point (required for updateBoundsPos)
|
|
617
|
+
this.anchorPoint.setMuted(x, y);
|
|
618
|
+
// then call updateBounds
|
|
619
|
+
this.updateBounds();
|
|
620
|
+
this.isDirty = true;
|
|
621
|
+
}
|
|
630
622
|
|
|
631
623
|
/**
|
|
632
624
|
* Prepare the rendering context before drawing (automatically called by melonJS).
|
package/src/renderable/sprite.js
CHANGED
|
@@ -10,7 +10,7 @@ import Color from "../math/color.js";
|
|
|
10
10
|
* An object to display a fixed or animated sprite on screen.
|
|
11
11
|
* @augments Renderable
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
export default class Sprite extends Renderable {
|
|
14
14
|
/**
|
|
15
15
|
* @param {number} x - the x coordinates of the sprite object
|
|
16
16
|
* @param {number} y - the y coordinates of the sprite object
|
|
@@ -307,7 +307,7 @@ import Color from "../math/color.js";
|
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
else {
|
|
310
|
-
|
|
310
|
+
frameObject = frame;
|
|
311
311
|
}
|
|
312
312
|
let frameObjectName = frameObject.name;
|
|
313
313
|
if (typeof(frameObjectName) === "number") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Color from "
|
|
2
|
-
import pool from "
|
|
3
|
-
import { getImage, getBinary } from "
|
|
4
|
-
import Renderable from "
|
|
1
|
+
import Color from "../../math/color.js";
|
|
2
|
+
import pool from "../../system/pooling.js";
|
|
3
|
+
import { getImage, getBinary } from "../../loader/loader.js";
|
|
4
|
+
import Renderable from "../renderable.js";
|
|
5
5
|
import TextMetrics from "./textmetrics.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,7 +9,7 @@ import TextMetrics from "./textmetrics.js";
|
|
|
9
9
|
* a bitmap font object
|
|
10
10
|
* @augments Renderable
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export default class BitmapText extends Renderable {
|
|
13
13
|
/**
|
|
14
14
|
* @param {number} x - position of the text object
|
|
15
15
|
* @param {number} y - position of the text object
|
|
@@ -210,8 +210,8 @@ import TextMetrics from "./textmetrics.js";
|
|
|
210
210
|
break;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
// adjust y pos based on alignment value
|
|
214
|
+
switch (this.textBaseline) {
|
|
215
215
|
case "middle":
|
|
216
216
|
ay = this.metrics.height * 0.5;
|
|
217
217
|
break;
|
|
@@ -233,7 +233,7 @@ import TextMetrics from "./textmetrics.js";
|
|
|
233
233
|
|
|
234
234
|
if (absolute === true) {
|
|
235
235
|
if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
|
|
236
|
-
|
|
236
|
+
bounds.translate(this.ancestor.getAbsolutePosition());
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
@@ -56,9 +56,9 @@ function createSpaceGlyph(glyphs) {
|
|
|
56
56
|
* Class for storing relevant data from the font file.
|
|
57
57
|
* @ignore
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
export default class BitmapTextData {
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
62
|
* @param {string} data - The bitmap font data pulled from the resource loader using me.loader.getBinary()
|
|
63
63
|
*/
|
|
64
64
|
constructor(data) {
|
|
@@ -116,14 +116,11 @@ function createSpaceGlyph(glyphs) {
|
|
|
116
116
|
this.lineHeight = parseFloat(getValueFromPair(lines[1], /lineHeight\=\d+/g));
|
|
117
117
|
|
|
118
118
|
let baseLine = parseFloat(getValueFromPair(lines[1], /base\=\d+/g));
|
|
119
|
-
|
|
120
119
|
let padY = this.padTop + this.padBottom;
|
|
121
|
-
|
|
122
120
|
let glyph = null;
|
|
123
121
|
|
|
124
|
-
let i;
|
|
125
122
|
|
|
126
|
-
for (i = 4; i < lines.length; i++) {
|
|
123
|
+
for (let i = 4; i < lines.length; i++) {
|
|
127
124
|
let line = lines[i];
|
|
128
125
|
let characterValues = line.split(/=|\s+/);
|
|
129
126
|
if (!line || /^kernings/.test(line)) {
|
|
@@ -164,7 +161,7 @@ function createSpaceGlyph(glyphs) {
|
|
|
164
161
|
createSpaceGlyph(this.glyphs);
|
|
165
162
|
|
|
166
163
|
let capGlyph = null;
|
|
167
|
-
for (i = 0; i < capChars.length; i++) {
|
|
164
|
+
for (let i = 0; i < capChars.length; i++) {
|
|
168
165
|
let capChar = capChars[i];
|
|
169
166
|
capGlyph = this.glyphs[capChar.charCodeAt(0)];
|
|
170
167
|
if (capGlyph) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Color from "
|
|
2
|
-
import { renderer as globalRenderer } from "
|
|
3
|
-
import pool from "
|
|
4
|
-
import Renderable from "
|
|
5
|
-
import { nextPowerOfTwo } from "
|
|
1
|
+
import Color from "../../math/color.js";
|
|
2
|
+
import { renderer as globalRenderer } from "../../video/video.js";
|
|
3
|
+
import pool from "../../system/pooling.js";
|
|
4
|
+
import Renderable from "../renderable.js";
|
|
5
|
+
import { nextPowerOfTwo } from "../../math/math.js";
|
|
6
6
|
import setContextStyle from "./textstyle.js";
|
|
7
7
|
import TextMetrics from "./textmetrics.js";
|
|
8
8
|
|
|
@@ -14,7 +14,6 @@ import TextMetrics from "./textmetrics.js";
|
|
|
14
14
|
* -> first char " " 32d (0x20);
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
const runits = ["ex", "em", "pt", "px"];
|
|
19
18
|
const toPX = [12, 24, 0.75, 1];
|
|
20
19
|
|
|
@@ -23,7 +22,7 @@ const toPX = [12, 24, 0.75, 1];
|
|
|
23
22
|
* a generic system font object.
|
|
24
23
|
* @augments Renderable
|
|
25
24
|
*/
|
|
26
|
-
|
|
25
|
+
export default class Text extends Renderable {
|
|
27
26
|
/**
|
|
28
27
|
* @param {number} x - position of the text object
|
|
29
28
|
* @param {number} y - position of the text object
|
|
@@ -76,16 +75,16 @@ const toPX = [12, 24, 0.75, 1];
|
|
|
76
75
|
* @name strokeStyle
|
|
77
76
|
* @default black
|
|
78
77
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
if (typeof settings.strokeStyle !== "undefined") {
|
|
79
|
+
if (settings.strokeStyle instanceof Color) {
|
|
80
|
+
this.strokeStyle = settings.strokeStyle;
|
|
81
|
+
} else {
|
|
82
|
+
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
83
|
+
this.strokeStyle = pool.pull("Color").parseCSS(settings.strokeStyle);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
this.strokeStyle = pool.pull("Color", 0, 0, 0);
|
|
87
|
+
}
|
|
89
88
|
|
|
90
89
|
/**
|
|
91
90
|
* sets the current line width, in pixels, when drawing stroke
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Bounds from "
|
|
1
|
+
import Bounds from "../../physics/bounds.js";
|
|
2
2
|
import Text from "./text.js";
|
|
3
3
|
import setContextStyle from "./textstyle.js";
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ import setContextStyle from "./textstyle.js";
|
|
|
7
7
|
* a Text Metrics object that contains helper for text manipulation
|
|
8
8
|
* @augments Bounds
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
export default class TextMetrics extends Bounds {
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {Text|BitmapText} ancestor - the parent object that contains this TextMetrics object
|
|
@@ -9,7 +9,7 @@ import pool from "./../system/pooling.js";
|
|
|
9
9
|
* trigger an event when colliding with another object
|
|
10
10
|
* @augments Renderable
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export default class Trigger extends Renderable {
|
|
13
13
|
/**
|
|
14
14
|
* @param {number} x - the x coordinates of the trigger area
|
|
15
15
|
* @param {number} y - the y coordinates of the trigger area
|
|
@@ -85,14 +85,14 @@ import pool from "./../system/pooling.js";
|
|
|
85
85
|
/**
|
|
86
86
|
* @ignore
|
|
87
87
|
*/
|
|
88
|
-
|
|
88
|
+
getTriggerSettings() {
|
|
89
89
|
let world = this.ancestor.getRootAncestor();
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
// Lookup for the container instance
|
|
91
|
+
if (typeof(this.triggerSettings.container) === "string") {
|
|
92
|
+
this.triggerSettings.container = world.getChildByName(this.triggerSettings.container)[0];
|
|
93
|
+
}
|
|
94
|
+
return this.triggerSettings;
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* @ignore
|
|
@@ -121,7 +121,7 @@ import pool from "./../system/pooling.js";
|
|
|
121
121
|
if (!this.fading) {
|
|
122
122
|
this.fading = true;
|
|
123
123
|
world.app.viewport.fadeIn(this.fade, this.duration,
|
|
124
|
-
|
|
124
|
+
() => this.onFadeComplete());
|
|
125
125
|
}
|
|
126
126
|
} else {
|
|
127
127
|
level.load(this.gotolevel, triggerSettings);
|
|
@@ -10,7 +10,7 @@ import pool from "../../system/pooling.js";
|
|
|
10
10
|
* Use this for example if you want to display a panel that contains text, images or other UI elements.
|
|
11
11
|
* @augments Container
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
export default class UIBaseElement extends Container {
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @param {number} x - The x position of the container
|
|
@@ -88,7 +88,7 @@ import pool from "../../system/pooling.js";
|
|
|
88
88
|
clicked(event) {
|
|
89
89
|
// Check if left mouse button is pressed
|
|
90
90
|
if (event.button === 0 && this.isClickable) {
|
|
91
|
-
this.
|
|
91
|
+
this.isDirty = true;
|
|
92
92
|
this.released = false;
|
|
93
93
|
if (this.isHoldable) {
|
|
94
94
|
timer.clearTimeout(this.holdTimeout);
|
|
@@ -122,7 +122,7 @@ import pool from "../../system/pooling.js";
|
|
|
122
122
|
*/
|
|
123
123
|
enter(event) {
|
|
124
124
|
this.hover = true;
|
|
125
|
-
this.
|
|
125
|
+
this.isDirty = true;
|
|
126
126
|
if (this.isDraggable === true) {
|
|
127
127
|
on(POINTERMOVE, this.pointerMove, this);
|
|
128
128
|
// to memorize where we grab the object
|
|
@@ -168,7 +168,7 @@ import pool from "../../system/pooling.js";
|
|
|
168
168
|
*/
|
|
169
169
|
leave(event) {
|
|
170
170
|
this.hover = false;
|
|
171
|
-
this.
|
|
171
|
+
this.isDirty = true;
|
|
172
172
|
if (this.isDraggable === true) {
|
|
173
173
|
// unregister on the global pointermove event
|
|
174
174
|
off(POINTERMOVE, this.pointerMove);
|
|
@@ -194,7 +194,7 @@ import pool from "../../system/pooling.js";
|
|
|
194
194
|
release(event) {
|
|
195
195
|
if (this.released === false) {
|
|
196
196
|
this.released = true;
|
|
197
|
-
this.
|
|
197
|
+
this.isDirty = true;
|
|
198
198
|
timer.clearTimeout(this.holdTimeout);
|
|
199
199
|
this.holdTimeout = -1;
|
|
200
200
|
return this.onRelease(event);
|
|
@@ -216,7 +216,7 @@ import pool from "../../system/pooling.js";
|
|
|
216
216
|
hold() {
|
|
217
217
|
timer.clearTimeout(this.holdTimeout);
|
|
218
218
|
this.holdTimeout = -1;
|
|
219
|
-
this.
|
|
219
|
+
this.isDirty = true;
|
|
220
220
|
if (!this.released) {
|
|
221
221
|
this.onHold();
|
|
222
222
|
}
|
|
@@ -7,7 +7,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
|
|
|
7
7
|
* This is a basic sprite based button which you can use in your Game UI.
|
|
8
8
|
* @augments Sprite
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
export default class UISpriteElement extends Sprite {
|
|
11
11
|
/**
|
|
12
12
|
* @param {number} x - the x coordinate of the UISpriteElement Object
|
|
13
13
|
* @param {number} y - the y coordinate of the UISpriteElement Object
|
|
@@ -93,7 +93,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
|
|
|
93
93
|
clicked(event) {
|
|
94
94
|
// Check if left mouse button is pressed
|
|
95
95
|
if (event.button === 0 && this.isClickable) {
|
|
96
|
-
this.
|
|
96
|
+
this.isDirty = true;
|
|
97
97
|
this.released = false;
|
|
98
98
|
if (this.isHoldable) {
|
|
99
99
|
timer.clearTimeout(this.holdTimeout);
|
|
@@ -119,7 +119,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
|
|
|
119
119
|
*/
|
|
120
120
|
enter(event) {
|
|
121
121
|
this.hover = true;
|
|
122
|
-
this.
|
|
122
|
+
this.isDirty = true;
|
|
123
123
|
return this.onOver(event);
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -137,7 +137,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
|
|
|
137
137
|
*/
|
|
138
138
|
leave(event) {
|
|
139
139
|
this.hover = false;
|
|
140
|
-
this.
|
|
140
|
+
this.isDirty = true;
|
|
141
141
|
this.release(event);
|
|
142
142
|
return this.onOut(event);
|
|
143
143
|
}
|
|
@@ -157,7 +157,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
|
|
|
157
157
|
release(event) {
|
|
158
158
|
if (this.released === false) {
|
|
159
159
|
this.released = true;
|
|
160
|
-
this.
|
|
160
|
+
this.isDirty = true;
|
|
161
161
|
timer.clearTimeout(this.holdTimeout);
|
|
162
162
|
this.holdTimeout = -1;
|
|
163
163
|
return this.onRelease(event);
|
|
@@ -179,7 +179,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
|
|
|
179
179
|
hold() {
|
|
180
180
|
timer.clearTimeout(this.holdTimeout);
|
|
181
181
|
this.holdTimeout = -1;
|
|
182
|
-
this.
|
|
182
|
+
this.isDirty = true;
|
|
183
183
|
if (!this.released) {
|
|
184
184
|
this.onHold();
|
|
185
185
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BitmapText from "
|
|
1
|
+
import BitmapText from "../text/bitmaptext.js";
|
|
2
2
|
import RoundRect from "../../geometries/roundrect.js";
|
|
3
3
|
import UIBaseElement from "./uibaseelement.js";
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ import UIBaseElement from "./uibaseelement.js";
|
|
|
8
8
|
* This is a basic base text button which you can use in your Game UI.
|
|
9
9
|
* @augments UIBaseElement
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default class UITextButton extends UIBaseElement {
|
|
12
12
|
/**
|
|
13
13
|
* A Bitmap Text Button with an outlined background border, filled with background color.
|
|
14
14
|
* It uses a RoundRect as background and changes the background color on hovering over.
|
package/src/state/stage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderer } from "./../video/video.js";
|
|
2
|
-
import
|
|
2
|
+
import * as event from "./../system/event.js";
|
|
3
3
|
import Camera2d from "./../camera/camera2d.js";
|
|
4
4
|
import Color from "./../math/color.js";
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ let default_settings = {
|
|
|
18
18
|
* through the state manager must inherit from this base class.
|
|
19
19
|
* @see state
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
export default class Stage {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @param {object} [settings] - The stage` parameters
|
|
@@ -87,7 +87,6 @@ let default_settings = {
|
|
|
87
87
|
* @ignore
|
|
88
88
|
*/
|
|
89
89
|
reset() {
|
|
90
|
-
|
|
91
90
|
// add all defined cameras
|
|
92
91
|
this.settings.cameras.forEach((camera) => {
|
|
93
92
|
this.cameras.set(camera.name, camera);
|
|
@@ -105,7 +104,7 @@ let default_settings = {
|
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
// reset the game
|
|
108
|
-
|
|
107
|
+
event.emit(event.STAGE_RESET, this);
|
|
109
108
|
|
|
110
109
|
// call the onReset Function
|
|
111
110
|
this.onResetEvent.apply(this, arguments);
|
|
@@ -120,8 +119,7 @@ let default_settings = {
|
|
|
120
119
|
* @returns {boolean}
|
|
121
120
|
*/
|
|
122
121
|
update(dt) {
|
|
123
|
-
|
|
124
|
-
let isDirty = game.world.update(dt);
|
|
122
|
+
let isDirty = false;
|
|
125
123
|
|
|
126
124
|
// update the camera/viewport
|
|
127
125
|
// iterate through all cameras
|
|
@@ -146,13 +144,15 @@ let default_settings = {
|
|
|
146
144
|
* @name draw
|
|
147
145
|
* @memberof Stage
|
|
148
146
|
* @ignore
|
|
149
|
-
* @param {
|
|
147
|
+
* @param {Renderer} renderer - the renderer object to draw with
|
|
148
|
+
* @param {World} world - the world object to draw
|
|
150
149
|
*/
|
|
151
|
-
draw(renderer) {
|
|
150
|
+
draw(renderer, world) {
|
|
151
|
+
|
|
152
152
|
// iterate through all cameras
|
|
153
153
|
this.cameras.forEach((camera) => {
|
|
154
154
|
// render the root container
|
|
155
|
-
camera.draw(renderer,
|
|
155
|
+
camera.draw(renderer, world);
|
|
156
156
|
|
|
157
157
|
// render the ambient light
|
|
158
158
|
if (this.ambientLight.alpha !== 0) {
|
|
@@ -172,9 +172,9 @@ let default_settings = {
|
|
|
172
172
|
|
|
173
173
|
// render all lights
|
|
174
174
|
this.lights.forEach((light) => {
|
|
175
|
-
light.preDraw(renderer,
|
|
176
|
-
light.draw(renderer,
|
|
177
|
-
light.postDraw(renderer,
|
|
175
|
+
light.preDraw(renderer, world);
|
|
176
|
+
light.draw(renderer, world);
|
|
177
|
+
light.postDraw(renderer, world);
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -209,7 +209,6 @@ let default_settings = {
|
|
|
209
209
|
if (typeof this.settings.onResetEvent === "function") {
|
|
210
210
|
this.settings.onResetEvent.apply(this, arguments);
|
|
211
211
|
}
|
|
212
|
-
|
|
213
212
|
}
|
|
214
213
|
|
|
215
214
|
/**
|