melonjs 17.1.0 → 17.2.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/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/_virtual/re.js +1 -1
- package/dist/melonjs.mjs/application/application.js +2 -2
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +13 -9
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +17 -17
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +1 -1
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/geometries/toarccanvas.js +4 -6
- package/dist/melonjs.mjs/index.js +4 -4
- 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 +1 -1
- package/dist/melonjs.mjs/input/pointer.js +1 -1
- package/dist/melonjs.mjs/input/pointerevent.js +1 -1
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +3 -3
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +5 -5
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +5 -2
- package/dist/melonjs.mjs/loader/loader.js +34 -5
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -4
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/binary.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/compressed_image.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseDDS.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX2.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePKM.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePVR.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/fetchdata.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/fontface.js +25 -15
- package/dist/melonjs.mjs/loader/parsers/image.js +3 -3
- package/dist/melonjs.mjs/loader/parsers/json.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/script.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/tmx.js +1 -1
- package/dist/melonjs.mjs/loader/parsers/video.js +1 -1
- package/dist/melonjs.mjs/math/color.js +6 -6
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +7 -7
- package/dist/melonjs.mjs/math/matrix3.js +2 -2
- package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
- package/dist/melonjs.mjs/math/observable_vector3.js +4 -4
- package/dist/melonjs.mjs/math/vector2.js +3 -3
- package/dist/melonjs.mjs/math/vector3.js +4 -4
- 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/node_modules/semver/classes/comparator.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/classes/range.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/classes/semver.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/clean.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/cmp.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/coerce.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/compare-build.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/compare-loose.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/compare.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/diff.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/eq.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/gt.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/gte.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/inc.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/lt.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/lte.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/major.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/minor.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/neq.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/parse.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/patch.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/prerelease.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/rcompare.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/rsort.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/satisfies.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/sort.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/functions/valid.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/internal/constants.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/internal/debug.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/internal/identifiers.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/internal/parse-options.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/internal/re.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/node_modules/lru-cache/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/node_modules/yallist/iterator.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/node_modules/yallist/yallist.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/gtr.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/intersects.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/ltr.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/max-satisfying.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/min-satisfying.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/min-version.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/outside.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/simplify.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/subset.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/to-comparators.js +1 -1
- package/dist/melonjs.mjs/node_modules/semver/ranges/valid.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +1 -1
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +4 -4
- package/dist/melonjs.mjs/physics/bounds.js +1 -1
- package/dist/melonjs.mjs/physics/collision.js +1 -1
- package/dist/melonjs.mjs/physics/detector.js +2 -2
- package/dist/melonjs.mjs/physics/quadtree.js +1 -1
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +1 -1
- package/dist/melonjs.mjs/physics/world.js +1 -1
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +2 -2
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/entity/entity.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
- package/dist/melonjs.mjs/renderable/light2d.js +7 -7
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +1 -1
- package/dist/melonjs.mjs/renderable/sprite.js +1 -1
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +1 -1
- package/dist/melonjs.mjs/renderable/text/glyph.js +1 -1
- package/dist/melonjs.mjs/renderable/text/text.js +1 -1
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/renderable/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/renderable/trigger.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
- package/dist/melonjs.mjs/state/stage.js +1 -1
- package/dist/melonjs.mjs/state/state.js +5 -5
- package/dist/melonjs.mjs/system/device.js +6 -6
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +1 -1
- package/dist/melonjs.mjs/system/platform.js +4 -2
- package/dist/melonjs.mjs/system/pooling.js +2 -2
- package/dist/melonjs.mjs/system/save.js +2 -2
- package/dist/melonjs.mjs/system/timer.js +2 -2
- package/dist/melonjs.mjs/tweens/easing.js +68 -70
- package/dist/melonjs.mjs/tweens/interpolation.js +29 -29
- package/dist/melonjs.mjs/tweens/tween.js +43 -43
- 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 +1 -1
- 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 +6 -5
- package/dist/melonjs.mjs/video/renderer.js +17 -69
- package/dist/melonjs.mjs/video/rendertarget/canvasrendertarget.js +12 -6
- package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/parser/aseprite.js +1 -1
- package/dist/melonjs.mjs/video/texture/parser/spritesheet.js +1 -1
- package/dist/melonjs.mjs/video/texture/parser/texturepacker.js +1 -1
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +1 -1
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
- 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 +5 -5
- 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 +8 -7
- package/dist/melonjs.module.js +358 -369
- package/dist/types/audio/audio.d.ts +8 -4
- package/dist/types/loader/cache.d.ts +1 -0
- package/dist/types/loader/loader.d.ts +7 -0
- package/dist/types/system/platform.d.ts +2 -0
- package/dist/types/video/renderer.d.ts +5 -15
- package/dist/types/video/rendertarget/canvasrendertarget.d.ts +6 -9
- package/package.json +13 -13
- package/src/application/application.js +1 -1
- package/src/application/header.js +1 -1
- package/src/audio/audio.js +12 -8
- package/src/geometries/path2d.js +16 -16
- package/src/index.js +2 -2
- package/src/level/tiled/TMXObject.js +1 -1
- package/src/level/tiled/TMXTileMap.js +1 -1
- package/src/level/tiled/TMXUtils.js +2 -2
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +4 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/src/loader/cache.js +3 -0
- package/src/loader/loader.js +33 -3
- package/src/loader/parsers/fontface.js +24 -14
- package/src/loader/parsers/image.js +2 -2
- package/src/math/color.js +5 -5
- package/src/math/matrix2.js +6 -6
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +2 -2
- package/src/math/observable_vector3.js +3 -3
- package/src/math/vector2.js +2 -2
- package/src/math/vector3.js +3 -3
- package/src/physics/body.js +3 -3
- package/src/physics/detector.js +1 -1
- package/src/renderable/container.js +1 -1
- package/src/renderable/light2d.js +6 -6
- package/src/state/state.js +4 -4
- package/src/system/device.js +5 -5
- package/src/system/platform.js +2 -0
- package/src/system/pooling.js +1 -1
- package/src/system/save.js +1 -1
- package/src/system/timer.js +1 -1
- package/src/tweens/easing.js +67 -69
- package/src/tweens/interpolation.js +28 -28
- package/src/tweens/tween.js +42 -42
- package/src/video/canvas/canvas_renderer.js +5 -4
- package/src/video/renderer.js +16 -68
- package/src/video/rendertarget/canvasrendertarget.js +11 -5
- package/src/video/webgl/utils/precision.js +4 -4
- package/src/video/webgl/webgl_renderer.js +7 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v17.
|
|
2
|
+
* melonJS Game Engine - v17.2.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
|
|
@@ -45,7 +45,7 @@ class Tween {
|
|
|
45
45
|
* autoStart : true
|
|
46
46
|
* }).onComplete(myFunc);
|
|
47
47
|
*/
|
|
48
|
-
constructor (
|
|
48
|
+
constructor (object) {
|
|
49
49
|
this.setProperties(object);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -53,7 +53,7 @@ class Tween {
|
|
|
53
53
|
* reset the tween object to default value
|
|
54
54
|
* @ignore
|
|
55
55
|
*/
|
|
56
|
-
onResetEvent(
|
|
56
|
+
onResetEvent(object) {
|
|
57
57
|
this.setProperties(object);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -89,7 +89,7 @@ class Tween {
|
|
|
89
89
|
this.isRenderable = false;
|
|
90
90
|
|
|
91
91
|
// Set all starting values present on the target object
|
|
92
|
-
for (
|
|
92
|
+
for (let field in object) {
|
|
93
93
|
if (typeof object !== "object") {
|
|
94
94
|
this._valuesStart[ field ] = parseFloat(object[field]);
|
|
95
95
|
}
|
|
@@ -139,7 +139,7 @@ class Tween {
|
|
|
139
139
|
* @param {boolean} [options.autoStart] - allow this tween to start automatically. Otherwise call me.Tween.start().
|
|
140
140
|
* @returns {Tween} this instance for object chaining
|
|
141
141
|
*/
|
|
142
|
-
to(
|
|
142
|
+
to(properties, options) {
|
|
143
143
|
|
|
144
144
|
this._valuesEnd = properties;
|
|
145
145
|
|
|
@@ -172,7 +172,7 @@ class Tween {
|
|
|
172
172
|
* @param {number} [time] - the current time when the tween was started
|
|
173
173
|
* @returns {Tween} this instance for object chaining
|
|
174
174
|
*/
|
|
175
|
-
start(
|
|
175
|
+
start(time = timer.getTime()) {
|
|
176
176
|
|
|
177
177
|
this._onStartCallbackFired = false;
|
|
178
178
|
|
|
@@ -181,25 +181,25 @@ class Tween {
|
|
|
181
181
|
|
|
182
182
|
this._startTime = time + this._delayTime;
|
|
183
183
|
|
|
184
|
-
for (
|
|
184
|
+
for (let property in this._valuesEnd) {
|
|
185
185
|
|
|
186
186
|
// check if an Array was provided as property value
|
|
187
|
-
if (
|
|
187
|
+
if (this._valuesEnd[ property ] instanceof Array) {
|
|
188
188
|
|
|
189
|
-
if (
|
|
189
|
+
if (this._valuesEnd[ property ].length === 0) {
|
|
190
190
|
|
|
191
191
|
continue;
|
|
192
192
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
// create a local copy of the Array with the start value at the front
|
|
196
|
-
this._valuesEnd[ property ] = [ this._object[ property ] ].concat(
|
|
196
|
+
this._valuesEnd[ property ] = [ this._object[ property ] ].concat(this._valuesEnd[ property ]);
|
|
197
197
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
this._valuesStart[ property ] = this._object[ property ];
|
|
201
201
|
|
|
202
|
-
if (
|
|
202
|
+
if ((this._valuesStart[ property ] instanceof Array) === false) {
|
|
203
203
|
this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -231,7 +231,7 @@ class Tween {
|
|
|
231
231
|
* @param {number} amount - delay amount expressed in milliseconds
|
|
232
232
|
* @returns {Tween} this instance for object chaining
|
|
233
233
|
*/
|
|
234
|
-
delay(
|
|
234
|
+
delay(amount) {
|
|
235
235
|
|
|
236
236
|
this._delayTime = amount;
|
|
237
237
|
return this;
|
|
@@ -246,7 +246,7 @@ class Tween {
|
|
|
246
246
|
* @param {number} times - amount of times the tween should be repeated
|
|
247
247
|
* @returns {Tween} this instance for object chaining
|
|
248
248
|
*/
|
|
249
|
-
repeat(
|
|
249
|
+
repeat(times) {
|
|
250
250
|
|
|
251
251
|
this._repeat = times;
|
|
252
252
|
return this;
|
|
@@ -263,7 +263,7 @@ class Tween {
|
|
|
263
263
|
* @param {boolean} yoyo
|
|
264
264
|
* @returns {Tween} this instance for object chaining
|
|
265
265
|
*/
|
|
266
|
-
yoyo(
|
|
266
|
+
yoyo(yoyo) {
|
|
267
267
|
|
|
268
268
|
this._yoyo = yoyo;
|
|
269
269
|
return this;
|
|
@@ -278,7 +278,7 @@ class Tween {
|
|
|
278
278
|
* @param {Tween.Easing} easing - easing function
|
|
279
279
|
* @returns {Tween} this instance for object chaining
|
|
280
280
|
*/
|
|
281
|
-
easing(
|
|
281
|
+
easing(easing) {
|
|
282
282
|
if (typeof easing !== "function") {
|
|
283
283
|
throw new Error("invalid easing function for me.Tween.easing()");
|
|
284
284
|
}
|
|
@@ -294,7 +294,7 @@ class Tween {
|
|
|
294
294
|
* @param {Tween.Interpolation} interpolation - interpolation function
|
|
295
295
|
* @returns {Tween} this instance for object chaining
|
|
296
296
|
*/
|
|
297
|
-
interpolation(
|
|
297
|
+
interpolation(interpolation) {
|
|
298
298
|
this._interpolationFunction = interpolation;
|
|
299
299
|
return this;
|
|
300
300
|
}
|
|
@@ -320,7 +320,7 @@ class Tween {
|
|
|
320
320
|
* @param {Function} onStartCallback - callback
|
|
321
321
|
* @returns {Tween} this instance for object chaining
|
|
322
322
|
*/
|
|
323
|
-
onStart(
|
|
323
|
+
onStart(onStartCallback) {
|
|
324
324
|
this._onStartCallback = onStartCallback;
|
|
325
325
|
return this;
|
|
326
326
|
}
|
|
@@ -333,7 +333,7 @@ class Tween {
|
|
|
333
333
|
* @param {Function} onUpdateCallback - callback
|
|
334
334
|
* @returns {Tween} this instance for object chaining
|
|
335
335
|
*/
|
|
336
|
-
onUpdate(
|
|
336
|
+
onUpdate(onUpdateCallback) {
|
|
337
337
|
this._onUpdateCallback = onUpdateCallback;
|
|
338
338
|
return this;
|
|
339
339
|
}
|
|
@@ -346,13 +346,13 @@ class Tween {
|
|
|
346
346
|
* @param {Function} onCompleteCallback - callback
|
|
347
347
|
* @returns {Tween} this instance for object chaining
|
|
348
348
|
*/
|
|
349
|
-
onComplete(
|
|
349
|
+
onComplete(onCompleteCallback) {
|
|
350
350
|
this._onCompleteCallback = onCompleteCallback;
|
|
351
351
|
return this;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
/** @ignore */
|
|
355
|
-
update(
|
|
355
|
+
update(dt) {
|
|
356
356
|
|
|
357
357
|
// the original Tween implementation expect
|
|
358
358
|
// a timestamp and not a time delta
|
|
@@ -361,17 +361,17 @@ class Tween {
|
|
|
361
361
|
|
|
362
362
|
let property;
|
|
363
363
|
|
|
364
|
-
if (
|
|
364
|
+
if (time < this._startTime) {
|
|
365
365
|
|
|
366
366
|
return true;
|
|
367
367
|
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
if (
|
|
370
|
+
if (this._onStartCallbackFired === false) {
|
|
371
371
|
|
|
372
|
-
if (
|
|
372
|
+
if (this._onStartCallback !== null) {
|
|
373
373
|
|
|
374
|
-
this._onStartCallback.call(
|
|
374
|
+
this._onStartCallback.call(this._object);
|
|
375
375
|
|
|
376
376
|
}
|
|
377
377
|
|
|
@@ -379,54 +379,54 @@ class Tween {
|
|
|
379
379
|
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
let elapsed = (
|
|
382
|
+
let elapsed = (time - this._startTime) / this._duration;
|
|
383
383
|
elapsed = elapsed > 1 ? 1 : elapsed;
|
|
384
384
|
|
|
385
|
-
let value = this._easingFunction(
|
|
385
|
+
let value = this._easingFunction(elapsed);
|
|
386
386
|
|
|
387
|
-
for (
|
|
387
|
+
for (property in this._valuesEnd) {
|
|
388
388
|
|
|
389
389
|
let start = this._valuesStart[ property ] || 0;
|
|
390
390
|
let end = this._valuesEnd[ property ];
|
|
391
391
|
|
|
392
|
-
if (
|
|
392
|
+
if (end instanceof Array) {
|
|
393
393
|
|
|
394
|
-
this._object[ property ] = this._interpolationFunction(
|
|
394
|
+
this._object[ property ] = this._interpolationFunction(end, value);
|
|
395
395
|
|
|
396
396
|
} else {
|
|
397
397
|
|
|
398
398
|
// Parses relative end values with start as base (e.g.: +10, -3)
|
|
399
|
-
if (
|
|
399
|
+
if (typeof(end) === "string") {
|
|
400
400
|
end = start + parseFloat(end);
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
// protect against non numeric properties.
|
|
404
|
-
if (
|
|
405
|
-
this._object[ property ] = start + (
|
|
404
|
+
if (typeof(end) === "number") {
|
|
405
|
+
this._object[ property ] = start + (end - start) * value;
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
if (
|
|
412
|
+
if (this._onUpdateCallback !== null) {
|
|
413
413
|
|
|
414
|
-
this._onUpdateCallback.call(
|
|
414
|
+
this._onUpdateCallback.call(this._object, value);
|
|
415
415
|
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
if (
|
|
418
|
+
if (elapsed === 1) {
|
|
419
419
|
|
|
420
|
-
if (
|
|
420
|
+
if (this._repeat > 0) {
|
|
421
421
|
|
|
422
|
-
if (
|
|
422
|
+
if (isFinite(this._repeat)) {
|
|
423
423
|
this._repeat--;
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
// reassign starting values, restart by making startTime = now
|
|
427
|
-
for (
|
|
427
|
+
for (property in this._valuesStartRepeat) {
|
|
428
428
|
|
|
429
|
-
if (
|
|
429
|
+
if (typeof(this._valuesEnd[ property ]) === "string") {
|
|
430
430
|
this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ]);
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -451,15 +451,15 @@ class Tween {
|
|
|
451
451
|
// remove the tween from the world container
|
|
452
452
|
game.world.removeChildNow(this);
|
|
453
453
|
|
|
454
|
-
if (
|
|
454
|
+
if (this._onCompleteCallback !== null) {
|
|
455
455
|
|
|
456
|
-
this._onCompleteCallback.call(
|
|
456
|
+
this._onCompleteCallback.call(this._object);
|
|
457
457
|
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
for (
|
|
460
|
+
for (let i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++) {
|
|
461
461
|
|
|
462
|
-
this._chainedTweens[ i ].start(
|
|
462
|
+
this._chainedTweens[ i ].start(time);
|
|
463
463
|
|
|
464
464
|
}
|
|
465
465
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v17.
|
|
2
|
+
* melonJS Game Engine - v17.2.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
|
|
@@ -44,12 +44,12 @@ class CanvasRenderer extends Renderer {
|
|
|
44
44
|
e.preventDefault();
|
|
45
45
|
this.isContextValid = false;
|
|
46
46
|
emit(ONCONTEXT_LOST, this);
|
|
47
|
-
}, false
|
|
47
|
+
}, false);
|
|
48
48
|
// ctx.restoreContext()
|
|
49
49
|
this.getCanvas().addEventListener("contextrestored", () => {
|
|
50
50
|
this.isContextValid = true;
|
|
51
51
|
emit(ONCONTEXT_RESTORED, this);
|
|
52
|
-
}, false
|
|
52
|
+
}, false);
|
|
53
53
|
|
|
54
54
|
// reset the renderer on game reset
|
|
55
55
|
on(GAME_RESET, () => {
|
|
@@ -594,12 +594,13 @@ class CanvasRenderer extends Renderer {
|
|
|
594
594
|
* renderer.restore();
|
|
595
595
|
*/
|
|
596
596
|
restore() {
|
|
597
|
+
const canvas = this.getCanvas();
|
|
597
598
|
this.getContext().restore();
|
|
598
599
|
this.currentColor.glArray[3] = this.getGlobalAlpha();
|
|
599
600
|
this.currentScissor[0] = 0;
|
|
600
601
|
this.currentScissor[1] = 0;
|
|
601
|
-
this.currentScissor[2] =
|
|
602
|
-
this.currentScissor[3] =
|
|
602
|
+
this.currentScissor[2] = canvas.width;
|
|
603
|
+
this.currentScissor[3] = canvas.height;
|
|
603
604
|
}
|
|
604
605
|
|
|
605
606
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v17.
|
|
2
|
+
* melonJS Game Engine - v17.2.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
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import Color from '../math/color.js';
|
|
9
9
|
import Matrix3d from '../math/matrix3.js';
|
|
10
|
-
import { createCanvas } from './video.js';
|
|
11
10
|
import { emit, CANVAS_ONRESIZE } from '../system/event.js';
|
|
12
|
-
import { platform } from '../system/device.js';
|
|
13
11
|
import Path2D from '../geometries/path2d.js';
|
|
14
12
|
import Vector2d from '../math/vector2.js';
|
|
15
13
|
import CanvasRenderTarget from './rendertarget/canvasrendertarget.js';
|
|
@@ -29,7 +27,10 @@ class Renderer {
|
|
|
29
27
|
* @name renderTarget
|
|
30
28
|
* @type {CanvasRenderTarget}
|
|
31
29
|
*/
|
|
32
|
-
this.renderTarget = new CanvasRenderTarget(options.width, options.height,
|
|
30
|
+
this.renderTarget = new CanvasRenderTarget(options.width, options.height,
|
|
31
|
+
// support case when a global canvas is available, e.g. webapp adapter for wechat
|
|
32
|
+
typeof globalThis.canvas !== "undefined" ? Object.assign(options, { canvas: globalThis.canvas }) : options
|
|
33
|
+
);
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* The given constructor options
|
|
@@ -95,19 +96,6 @@ class Renderer {
|
|
|
95
96
|
*/
|
|
96
97
|
this.currentBlendMode = "none";
|
|
97
98
|
|
|
98
|
-
// create the main screen canvas
|
|
99
|
-
if (platform.ejecta === true) {
|
|
100
|
-
// a main canvas is already automatically created by Ejecta
|
|
101
|
-
this.canvas = globalThis.document.getElementById("canvas");
|
|
102
|
-
} else if (typeof globalThis.canvas !== "undefined") {
|
|
103
|
-
// a global canvas is available, e.g. webapp adapter for wechat
|
|
104
|
-
this.canvas = globalThis.canvas;
|
|
105
|
-
} else if (typeof this.settings.canvas !== "undefined") {
|
|
106
|
-
this.canvas = this.settings.canvas;
|
|
107
|
-
} else {
|
|
108
|
-
this.canvas = createCanvas(this.settings.width, this.settings.height);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
99
|
// global color
|
|
112
100
|
this.currentColor = new Color(0, 0, 0, 1.0);
|
|
113
101
|
|
|
@@ -172,7 +160,7 @@ class Renderer {
|
|
|
172
160
|
}
|
|
173
161
|
|
|
174
162
|
/**
|
|
175
|
-
* return a reference to the canvas which this renderer draws to
|
|
163
|
+
* return a reference to the current render target corresponding canvas which this renderer draws to
|
|
176
164
|
* @returns {HTMLCanvasElement}
|
|
177
165
|
*/
|
|
178
166
|
getCanvas() {
|
|
@@ -180,7 +168,7 @@ class Renderer {
|
|
|
180
168
|
}
|
|
181
169
|
|
|
182
170
|
/**
|
|
183
|
-
* return a reference to
|
|
171
|
+
* return a reference to the current render target corresponding Context
|
|
184
172
|
* @returns {CanvasRenderingContext2D|WebGLRenderingContext}
|
|
185
173
|
*/
|
|
186
174
|
getContext() {
|
|
@@ -195,42 +183,6 @@ class Renderer {
|
|
|
195
183
|
return this.currentBlendMode;
|
|
196
184
|
}
|
|
197
185
|
|
|
198
|
-
/**
|
|
199
|
-
* Returns the 2D Context object of the given Canvas<br>
|
|
200
|
-
* Also configures anti-aliasing and blend modes based on constructor options.
|
|
201
|
-
* @param {HTMLCanvasElement} canvas
|
|
202
|
-
* @param {boolean} [transparent=true] - use false to disable transparency
|
|
203
|
-
* @returns {CanvasRenderingContext2D}
|
|
204
|
-
*/
|
|
205
|
-
getContext2d(canvas, transparent) {
|
|
206
|
-
if (typeof canvas === "undefined" || canvas === null) {
|
|
207
|
-
throw new Error(
|
|
208
|
-
"You must pass a canvas element in order to create " +
|
|
209
|
-
"a 2d context"
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (typeof canvas.getContext === "undefined") {
|
|
214
|
-
throw new Error(
|
|
215
|
-
"Your browser does not support HTML5 canvas."
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (typeof transparent !== "boolean") {
|
|
220
|
-
transparent = true;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
let _context = canvas.getContext("2d", {
|
|
224
|
-
"alpha" : transparent
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
if (!_context.canvas) {
|
|
228
|
-
_context.canvas = canvas;
|
|
229
|
-
}
|
|
230
|
-
this.setAntiAlias(_context, this.settings.antiAlias);
|
|
231
|
-
return _context;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
186
|
/**
|
|
235
187
|
* get the current fill & stroke style color.
|
|
236
188
|
* @returns {Color} current global color
|
|
@@ -279,12 +231,11 @@ class Renderer {
|
|
|
279
231
|
}
|
|
280
232
|
|
|
281
233
|
/**
|
|
282
|
-
* enable/disable image smoothing (scaling interpolation) for the
|
|
283
|
-
* @param {CanvasRenderingContext2D} context
|
|
234
|
+
* enable/disable image smoothing (scaling interpolation) for the current render target
|
|
284
235
|
* @param {boolean} [enable=false]
|
|
285
236
|
*/
|
|
286
|
-
setAntiAlias(
|
|
287
|
-
this.renderTarget.setAntiAlias(
|
|
237
|
+
setAntiAlias(enable) {
|
|
238
|
+
this.renderTarget.setAntiAlias(enable);
|
|
288
239
|
}
|
|
289
240
|
|
|
290
241
|
/**
|
|
@@ -347,25 +298,22 @@ class Renderer {
|
|
|
347
298
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src - the source image to be tinted
|
|
348
299
|
* @param {Color|string} color - the color that will be used to tint the image
|
|
349
300
|
* @param {string} [mode="multiply"] - the composition mode used to tint the image
|
|
350
|
-
* @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
|
|
301
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas or offscreencanvas (if supported) element representing the tinted image
|
|
351
302
|
*/
|
|
352
|
-
tint(src, color, mode) {
|
|
353
|
-
|
|
354
|
-
let
|
|
355
|
-
|
|
356
|
-
context.save();
|
|
303
|
+
tint(src, color, mode = "multiply") {
|
|
304
|
+
const attributes = { context:"2d", offscreenCanvas: true, transparent: true, antiAlias: this.settings.antiAlias };
|
|
305
|
+
let canvasTexture = new CanvasRenderTarget(src.width, src.height, attributes);
|
|
306
|
+
let context = canvasTexture.context;
|
|
357
307
|
|
|
358
308
|
context.fillStyle = color instanceof Color ? color.toRGB() : color;
|
|
359
309
|
context.fillRect(0, 0, src.width, src.height);
|
|
360
310
|
|
|
361
|
-
context.globalCompositeOperation = mode
|
|
311
|
+
context.globalCompositeOperation = mode;
|
|
362
312
|
context.drawImage(src, 0, 0);
|
|
363
313
|
context.globalCompositeOperation = "destination-atop";
|
|
364
314
|
context.drawImage(src, 0, 0);
|
|
365
315
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return canvas;
|
|
316
|
+
return canvasTexture.canvas;
|
|
369
317
|
}
|
|
370
318
|
|
|
371
319
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v17.
|
|
2
|
+
* melonJS Game Engine - v17.2.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
|
|
@@ -35,7 +35,6 @@ function createContext(canvas, attributes) {
|
|
|
35
35
|
// 2d/canvas mode
|
|
36
36
|
context = canvas.getContext(attributes.context, { willReadFrequently: attributes.willReadFrequently });
|
|
37
37
|
} else if (attributes.context === "webgl") {
|
|
38
|
-
|
|
39
38
|
let attr = {
|
|
40
39
|
alpha : attributes.transparent,
|
|
41
40
|
antialias : attributes.antiAlias,
|
|
@@ -47,8 +46,8 @@ function createContext(canvas, attributes) {
|
|
|
47
46
|
failIfMajorPerformanceCaveat : attributes.failIfMajorPerformanceCaveat
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
// attempt to create a WebGL2 context
|
|
51
|
-
if (attributes.preferWebGL1
|
|
49
|
+
// attempt to create a WebGL2 context unless not requested
|
|
50
|
+
if (attributes.preferWebGL1 !== true) {
|
|
52
51
|
context = canvas.getContext("webgl2", attr);
|
|
53
52
|
if (context) {
|
|
54
53
|
WebGLVersion = 2;
|
|
@@ -83,8 +82,10 @@ class CanvasRenderTarget {
|
|
|
83
82
|
/**
|
|
84
83
|
* @param {number} width - the desired width of the canvas
|
|
85
84
|
* @param {number} height - the desired height of the canvas
|
|
86
|
-
* @param {
|
|
87
|
-
* @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl"
|
|
85
|
+
* @param {Settings} attributes - The attributes to create both the canvas and context
|
|
86
|
+
* @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl")
|
|
87
|
+
* @param {boolean} [attributes.preferWebGL1=false] - set to true for force using WebGL1 instead of WebGL2 (if supported)
|
|
88
|
+
* @param {boolean} [attributes.transparent=false] - specify if the canvas contains an alpha channel
|
|
88
89
|
* @param {boolean} [attributes.offscreenCanvas=false] - will create an offscreenCanvas if true instead of a standard canvas
|
|
89
90
|
* @param {boolean} [attributes.willReadFrequently=false] - Indicates whether or not a lot of read-back operations are planned
|
|
90
91
|
* @param {boolean} [attributes.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
@@ -105,6 +106,11 @@ class CanvasRenderTarget {
|
|
|
105
106
|
// clean up the given attributes
|
|
106
107
|
this.attributes = Object.assign({}, defaultAttributes, attributes);
|
|
107
108
|
|
|
109
|
+
// make sure context is defined
|
|
110
|
+
if (typeof attributes.context === "undefined") {
|
|
111
|
+
attributes.context = "2d";
|
|
112
|
+
}
|
|
113
|
+
|
|
108
114
|
// used the given canvas if any
|
|
109
115
|
if (typeof attributes.canvas !== "undefined") {
|
|
110
116
|
this.canvas = attributes.canvas;
|