melonjs 14.4.0 → 14.5.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 +11 -55
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/application/header.js +1 -1
- 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 +4 -4
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +43 -9
- package/dist/melonjs.mjs/geometries/ellipse.js +2 -3
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +18 -42
- package/dist/melonjs.mjs/geometries/point.js +1 -6
- package/dist/melonjs.mjs/geometries/poly.js +2 -5
- package/dist/melonjs.mjs/geometries/rectangle.js +13 -9
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +8 -6
- package/dist/melonjs.mjs/input/gamepad.js +10 -16
- 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 +2 -16
- 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 +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -8
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +8 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +5 -5
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- 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 +24 -0
- package/dist/melonjs.mjs/loader/loader.js +331 -716
- package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +281 -0
- package/dist/melonjs.mjs/loader/settings.js +91 -0
- package/dist/melonjs.mjs/math/color.js +1 -1
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +7 -9
- package/dist/melonjs.mjs/math/matrix3.js +18 -21
- package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
- package/dist/melonjs.mjs/math/observable_vector3.js +3 -4
- package/dist/melonjs.mjs/math/vector2.js +3 -3
- package/dist/melonjs.mjs/math/vector3.js +3 -4
- 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 +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 +3 -3
- 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 +18 -14
- package/dist/melonjs.mjs/physics/bounds.js +18 -70
- package/dist/melonjs.mjs/physics/collision.js +1 -1
- package/dist/melonjs.mjs/physics/detector.js +1 -1
- 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 +25 -19
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -1
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +126 -105
- package/dist/melonjs.mjs/renderable/sprite.js +33 -54
- 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 +2 -2
- package/dist/melonjs.mjs/system/device.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/system/pooling.js +8 -18
- 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 +66 -8
- package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
- 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 +1 -1
- 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 +2 -2
- package/dist/melonjs.mjs/utils/utils.js +2 -4
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
- package/dist/melonjs.mjs/video/renderer.js +1 -1
- package/dist/melonjs.mjs/video/texture/atlas.js +10 -9
- package/dist/melonjs.mjs/video/texture/cache.js +3 -3
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
- package/{src/video/webgl → dist/melonjs.mjs/video/webgl/compositors}/webgl_compositor.js +28 -205
- 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 +1 -1
- 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_compositor.js +2 -2
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +2 -2
- package/dist/melonjs.module.js +17844 -17809
- package/dist/types/entity/entity.d.ts +2 -2
- package/dist/types/geometries/path2d.d.ts +5 -31
- package/dist/types/geometries/point.d.ts +2 -7
- package/dist/types/geometries/poly.d.ts +0 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/loader/cache.d.ts +7 -0
- package/dist/types/loader/loader.d.ts +166 -181
- package/dist/types/loader/parser.d.ts +41 -0
- package/dist/types/loader/settings.d.ts +57 -0
- package/dist/types/particles/emitter.d.ts +4 -4
- package/dist/types/physics/bounds.d.ts +29 -84
- package/dist/types/renderable/container.d.ts +0 -11
- package/dist/types/renderable/renderable.d.ts +37 -31
- package/dist/types/renderable/sprite.d.ts +3 -3
- package/dist/types/state/state.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +2 -2
- package/dist/types/video/renderer.d.ts +1 -1
- package/dist/types/video/webgl/compositors/compositor.d.ts +101 -0
- package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
- package/dist/types/video/webgl/webgl_renderer.d.ts +1 -1
- package/package.json +16 -15
- package/src/audio/audio.js +3 -3
- package/src/entity/entity.js +42 -8
- package/src/geometries/ellipse.js +1 -2
- package/src/geometries/path2d.js +17 -41
- package/src/geometries/point.js +0 -5
- package/src/geometries/poly.js +1 -4
- package/src/geometries/rectangle.js +12 -8
- package/src/index.js +2 -2
- package/src/input/gamepad.js +9 -15
- package/src/input/pointerevent.js +1 -15
- package/src/level/level.js +2 -2
- package/src/level/tiled/TMXLayer.js +0 -7
- package/src/level/tiled/TMXTileMap.js +7 -3
- package/src/level/tiled/TMXTileset.js +4 -4
- package/src/loader/cache.js +16 -0
- package/src/loader/loader.js +339 -711
- package/src/loader/loadingscreen.js +3 -3
- package/src/loader/parser.js +279 -0
- package/src/loader/settings.js +85 -0
- package/src/math/matrix2.js +6 -8
- package/src/math/matrix3.js +17 -20
- package/src/math/observable_vector2.js +2 -2
- package/src/math/observable_vector3.js +2 -3
- package/src/math/vector2.js +2 -2
- package/src/math/vector3.js +2 -3
- package/src/particles/emitter.js +2 -2
- package/src/physics/body.js +17 -13
- package/src/physics/bounds.js +17 -69
- package/src/renderable/container.js +24 -18
- package/src/renderable/imagelayer.js +6 -0
- package/src/renderable/renderable.js +125 -104
- package/src/renderable/sprite.js +32 -53
- package/src/state/state.js +1 -1
- package/src/system/pooling.js +7 -17
- package/src/text/bitmaptext.js +65 -7
- package/src/utils/string.js +1 -1
- package/src/utils/utils.js +1 -3
- package/src/video/texture/atlas.js +9 -8
- package/src/video/texture/cache.js +2 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/compositors/compositor.js +227 -0
- package/src/video/webgl/compositors/webgl_compositor.js +300 -0
- package/src/video/webgl/webgl_renderer.js +1 -1
package/README.md
CHANGED
|
@@ -3,10 +3,12 @@ melonJS 2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
[](https://travis-ci.org/melonjs/melonJS)
|
|
6
|
-
[](https://bundlephobia.com/result?p=melonjs)
|
|
7
|
+
[](https://bundlephobia.com/result?p=melonjs)
|
|
7
8
|
[](https://www.npmjs.com/package/melonjs)
|
|
8
9
|
[](https://www.jsdelivr.com/package/npm/melonjs)
|
|
9
10
|
[](https://www.boss.dev/issues/repo/melonjs/melonJS)
|
|
11
|
+
[](CODE_OF_CONDUCT.md)
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
A fresh, _modern_ & lightweight HTML5 game engine
|
|
@@ -184,63 +186,17 @@ Or can simply be added to your html, using [jsDeliver](https://www.jsdelivr.com/
|
|
|
184
186
|
```
|
|
185
187
|
> Note: starting from the 10.0.0 version, the debug plugin is no longer provided as part of the melonJS library release, and has been moved to the official [boilerplate](https://github.com/melonjs/es6-boilerplate)
|
|
186
188
|
|
|
187
|
-
|
|
189
|
+
Contributing
|
|
188
190
|
-------------------------------------------------------------------------------
|
|
189
|
-
For most users, all you probably want is to use melonJS, and all you need then is just to download the latest built [release](https://github.com/melonjs/melonJS#download-melonjs) to get started.
|
|
191
|
+
For most users, all you probably want is to use melonJS, and all you need then is just to download the latest built [release](https://github.com/melonjs/melonJS#download-melonjs) to get started.
|
|
190
192
|
|
|
191
|
-
|
|
193
|
+
If you want to start to be part and contribute to the project, make sure to read our [Contributing Guide](CONTRIBUTING.md) before starting submitting changes or new features.
|
|
192
194
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
Once Node.js and NPM have been installed, you need to install build dependencies,
|
|
196
|
-
by executing the following in the folder where you cloned the repository :
|
|
197
|
-
|
|
198
|
-
$ [sudo] npm install
|
|
199
|
-
|
|
200
|
-
Then build the melonJS source by running:
|
|
201
|
-
|
|
202
|
-
$ npm run build
|
|
203
|
-
|
|
204
|
-
The generated files will be available under the `build` directory :
|
|
205
|
-
- `melonjs.module.js` : plain ES6 module
|
|
206
|
-
- `melonjs.mjs` : a ES6 chunk directory used for tree-shaking
|
|
207
|
-
|
|
208
|
-
If you need to create the corresponding typing you can use the follwing :
|
|
209
|
-
|
|
210
|
-
$ npm run types
|
|
211
|
-
|
|
212
|
-
This will generate all the `.d.ts` file under the `dist/types` directory.
|
|
213
|
-
|
|
214
|
-
To run the melonJS test suite simply use the following:
|
|
215
|
-
|
|
216
|
-
$ npm run test
|
|
217
|
-
|
|
218
|
-
This will run the jasmine spec tests with the output displayed on the shell. Do
|
|
219
|
-
note that the latest Chrome version is required, as the test unit will run the
|
|
220
|
-
Browser in a headless mode (in case of failed tests, upgrade your browser).
|
|
221
|
-
|
|
222
|
-
Last but not least, if you really want to contribute, but not sure how, you can
|
|
223
|
-
always check our [discussions](https://github.com/melonjs/melonJS/discussions/categories/ideas) list to get some idea on where to start.
|
|
224
|
-
|
|
225
|
-
Building the documentation
|
|
226
|
-
-------------------------------------------------------------------------------
|
|
227
|
-
Similarly, you can build your own copy of the docs locally by running :
|
|
228
|
-
|
|
229
|
-
$ npm run doc
|
|
230
|
-
|
|
231
|
-
The generated documentation will be available in the `docs` directory
|
|
232
|
-
|
|
233
|
-
WIP Builds
|
|
195
|
+
Contributors
|
|
234
196
|
-------------------------------------------------------------------------------
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
-------------------------------------------------------------------------------
|
|
239
|
-
If you need technical support, you can contact us through the following channels :
|
|
240
|
-
* Forums: with melonJS 2 we moved to a new discourse [forum](https://melonjs.discourse.group), but we can still also find the previous one [here](http://www.html5gamedevs.com/forum/32-melonjs/)
|
|
241
|
-
* Chat: come and chat with us on [discord](https://discord.gg/aur7JMk), or [gitter](https://gitter.im/melonjs/public)
|
|
242
|
-
* we tried to keep our [wikipage](https://github.com/melonjs/melonJS/wiki) up-to-date with useful links, tutorials, and anything related melonJS.
|
|
243
|
-
|
|
197
|
+
<a href = "https://github.com/melonjs/melonJS/graphs/contributors">
|
|
198
|
+
<img src = "https://contrib.rocks/image?repo=melonJS/melonjs"/>
|
|
199
|
+
</a>
|
|
244
200
|
|
|
245
201
|
Sponsors
|
|
246
202
|
-------------------------------------------------------------------------------
|
|
@@ -248,4 +204,4 @@ Support the development of melonJS by [becoming a sponsor](https://github.com/sp
|
|
|
248
204
|
|
|
249
205
|
[](https://www.melongaming.com)
|
|
250
206
|
|
|
251
|
-
[]()
|
|
207
|
+
[](https://www.altbyte.com)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.5.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,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import '../node_modules/howler/dist/howler.js';
|
|
9
9
|
import { clamp } from '../math/math.js';
|
|
10
|
-
import
|
|
10
|
+
import { nocache, withCredentials } from '../loader/settings.js';
|
|
11
11
|
import { isDataUrl } from '../utils/string.js';
|
|
12
12
|
import { __exports as howler } from '../_virtual/howler.js';
|
|
13
13
|
|
|
@@ -153,7 +153,7 @@ function load(sound, html5, onload_cb, onerror_cb) {
|
|
|
153
153
|
urls.push(sound.src);
|
|
154
154
|
} else {
|
|
155
155
|
for (var i = 0; i < audioExts.length; i++) {
|
|
156
|
-
urls.push(sound.src + sound.name + "." + audioExts[i] +
|
|
156
|
+
urls.push(sound.src + sound.name + "." + audioExts[i] + nocache);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -161,7 +161,7 @@ function load(sound, html5, onload_cb, onerror_cb) {
|
|
|
161
161
|
src : urls,
|
|
162
162
|
volume : howler.Howler.volume(),
|
|
163
163
|
html5 : html5 === true,
|
|
164
|
-
xhrWithCredentials :
|
|
164
|
+
xhrWithCredentials : withCredentials,
|
|
165
165
|
/**
|
|
166
166
|
* @ignore
|
|
167
167
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.5.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
|
|
@@ -59,10 +59,10 @@ import Body from '../physics/body.js';
|
|
|
59
59
|
|
|
60
60
|
// Update anchorPoint
|
|
61
61
|
if (settings.anchorPoint) {
|
|
62
|
-
this.anchorPoint.
|
|
62
|
+
this.anchorPoint.setMuted(settings.anchorPoint.x, settings.anchorPoint.y);
|
|
63
63
|
} else {
|
|
64
64
|
// for backward compatibility
|
|
65
|
-
this.anchorPoint.
|
|
65
|
+
this.anchorPoint.setMuted(0, 0);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// set the sprite name if specified
|
|
@@ -146,6 +146,7 @@ import Body from '../physics/body.js';
|
|
|
146
146
|
if (value instanceof Renderable) {
|
|
147
147
|
this.children[0] = value;
|
|
148
148
|
this.children[0].ancestor = this;
|
|
149
|
+
this.updateBounds();
|
|
149
150
|
} else {
|
|
150
151
|
throw new Error(value + "should extend me.Renderable");
|
|
151
152
|
}
|
|
@@ -160,17 +161,50 @@ import Body from '../physics/body.js';
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
/**
|
|
163
|
-
* update the
|
|
164
|
+
* update the bounding box for this entity.
|
|
165
|
+
* @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
|
|
166
|
+
* @returns {Bounds} this entity bounding box Rectangle object
|
|
167
|
+
*/
|
|
168
|
+
updateBounds(absolute = true) {
|
|
169
|
+
var bounds = this.getBounds();
|
|
170
|
+
|
|
171
|
+
bounds.clear();
|
|
172
|
+
bounds.addFrame(
|
|
173
|
+
0,
|
|
174
|
+
0,
|
|
175
|
+
this.width,
|
|
176
|
+
this.height
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
// add each renderable bounds
|
|
180
|
+
if (this.children && this.children.length > 0) {
|
|
181
|
+
bounds.addBounds(this.children[0].getBounds());
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (this.body) {
|
|
185
|
+
bounds.addBounds(this.body.getBounds());
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (absolute === true) {
|
|
189
|
+
bounds.centerOn(this.pos.x + bounds.x + bounds.width / 2, this.pos.y + bounds.y + bounds.height / 2);
|
|
190
|
+
if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
|
|
191
|
+
bounds.translate(this.ancestor.getAbsolutePosition());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return bounds;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* update the bounds when the body is modified
|
|
164
201
|
* @ignore
|
|
165
202
|
* @name onBodyUpdate
|
|
166
203
|
* @memberof Entity
|
|
167
204
|
* @param {Body} body - the body whose bounds to update
|
|
168
205
|
*/
|
|
169
|
-
onBodyUpdate(
|
|
170
|
-
|
|
171
|
-
this.getBounds().addBounds(body.getBounds(), true);
|
|
172
|
-
// update the bounds pos
|
|
173
|
-
this.updateBoundsPos(this.pos.x, this.pos.y);
|
|
206
|
+
onBodyUpdate() {
|
|
207
|
+
this.updateBounds();
|
|
174
208
|
}
|
|
175
209
|
|
|
176
210
|
preDraw(renderer) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.5.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
|
|
@@ -133,8 +133,7 @@ import pool from '../system/pooling.js';
|
|
|
133
133
|
* @param {number} [y=x]
|
|
134
134
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
135
135
|
*/
|
|
136
|
-
scale(x, y) {
|
|
137
|
-
y = typeof (y) !== "undefined" ? y : x;
|
|
136
|
+
scale(x, y = x) {
|
|
138
137
|
return this.setShape(
|
|
139
138
|
this.pos.x,
|
|
140
139
|
this.pos.y,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.5.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
|
|
@@ -18,20 +18,14 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
18
18
|
constructor() {
|
|
19
19
|
/**
|
|
20
20
|
* the points defining the current path
|
|
21
|
-
* @
|
|
22
|
-
* @type {Vector2d[]}
|
|
23
|
-
* @name points
|
|
24
|
-
* @memberof Path2D#
|
|
21
|
+
* @type {Point[]}
|
|
25
22
|
*/
|
|
26
23
|
this.points = [];
|
|
27
24
|
|
|
28
25
|
/**
|
|
29
26
|
* space between interpolated points for quadratic and bezier curve approx. in pixels.
|
|
30
|
-
* @public
|
|
31
27
|
* @type {number}
|
|
32
|
-
* @name arcResolution
|
|
33
28
|
* @default 5
|
|
34
|
-
* @memberof Path2D#
|
|
35
29
|
*/
|
|
36
30
|
this.arcResolution = 5;
|
|
37
31
|
|
|
@@ -41,8 +35,6 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
41
35
|
|
|
42
36
|
/**
|
|
43
37
|
* begin a new path
|
|
44
|
-
* @name beginPath
|
|
45
|
-
* @memberof Path2D
|
|
46
38
|
*/
|
|
47
39
|
beginPath() {
|
|
48
40
|
// empty the cache and recycle all vectors
|
|
@@ -56,21 +48,17 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
56
48
|
* causes the point of the pen to move back to the start of the current path.
|
|
57
49
|
* It tries to draw a straight line from the current point to the start.
|
|
58
50
|
* If the shape has already been closed or has only one point, this function does nothing.
|
|
59
|
-
* @name closePath
|
|
60
|
-
* @memberof Path2D
|
|
61
51
|
*/
|
|
62
52
|
closePath() {
|
|
63
53
|
var points = this.points;
|
|
64
54
|
if (points.length > 1 && !points[points.length-1].equals(points[0])) {
|
|
65
|
-
points.push(pool.pull("
|
|
55
|
+
points.push(pool.pull("Point", points[0].x, points[0].y));
|
|
66
56
|
}
|
|
67
57
|
}
|
|
68
58
|
|
|
69
59
|
/**
|
|
70
60
|
* triangulate the shape defined by this path into an array of triangles
|
|
71
|
-
* @
|
|
72
|
-
* @memberof Path2D
|
|
73
|
-
* @returns {Vector2d[]}
|
|
61
|
+
* @returns {Point[]}
|
|
74
62
|
*/
|
|
75
63
|
triangulatePath() {
|
|
76
64
|
var i = 0;
|
|
@@ -78,13 +66,15 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
78
66
|
var vertices = this.vertices;
|
|
79
67
|
var indices = earcutExports(points.flatMap(p => [p.x, p.y]));
|
|
80
68
|
|
|
69
|
+
// pre-allocate vertices if necessary
|
|
70
|
+
while (vertices.length < indices.length) {
|
|
71
|
+
vertices.push(pool.pull("Point"));
|
|
72
|
+
}
|
|
73
|
+
|
|
81
74
|
// calculate all vertices
|
|
82
75
|
for (i = 0; i < indices.length; i++ ) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
vertices[i] = pool.pull("Vector2d");
|
|
86
|
-
}
|
|
87
|
-
vertices[i].set(points[indices[i]].x, points[indices[i]].y);
|
|
76
|
+
var point = points[indices[i]];
|
|
77
|
+
vertices[i].set(point.x, point.y);
|
|
88
78
|
}
|
|
89
79
|
|
|
90
80
|
// recycle overhead from a previous triangulation
|
|
@@ -98,31 +88,25 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
98
88
|
|
|
99
89
|
/**
|
|
100
90
|
* moves the starting point of the current path to the (x, y) coordinates.
|
|
101
|
-
* @name moveTo
|
|
102
|
-
* @memberof Path2D
|
|
103
91
|
* @param {number} x - the x-axis (horizontal) coordinate of the point.
|
|
104
92
|
* @param {number} y - the y-axis (vertical) coordinate of the point.
|
|
105
93
|
*/
|
|
106
94
|
moveTo(x, y) {
|
|
107
|
-
this.points.push(pool.pull("
|
|
95
|
+
this.points.push(pool.pull("Point", x, y));
|
|
108
96
|
}
|
|
109
97
|
|
|
110
98
|
/**
|
|
111
99
|
* connects the last point in the current patch to the (x, y) coordinates with a straight line.
|
|
112
|
-
* @name lineTo
|
|
113
|
-
* @memberof Path2D
|
|
114
100
|
* @param {number} x - the x-axis coordinate of the line's end point.
|
|
115
101
|
* @param {number} y - the y-axis coordinate of the line's end point.
|
|
116
102
|
*/
|
|
117
103
|
lineTo(x, y) {
|
|
118
|
-
this.points.push(pool.pull("
|
|
104
|
+
this.points.push(pool.pull("Point", x, y));
|
|
119
105
|
}
|
|
120
106
|
|
|
121
107
|
/**
|
|
122
108
|
* adds an arc to the current path which is centered at (x, y) position with the given radius,
|
|
123
109
|
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
|
|
124
|
-
* @name arc
|
|
125
|
-
* @memberof Path2D
|
|
126
110
|
* @param {number} x - the horizontal coordinate of the arc's center.
|
|
127
111
|
* @param {number} y - the vertical coordinate of the arc's center.
|
|
128
112
|
* @param {number} radius - the arc's radius. Must be positive.
|
|
@@ -162,16 +146,14 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
162
146
|
|
|
163
147
|
var angle = startAngle;
|
|
164
148
|
for (var j = 0; j < nr_of_interpolation_points; j++) {
|
|
165
|
-
points.push(pool.pull("
|
|
149
|
+
points.push(pool.pull("Point", x + radius * Math.cos(angle), y + radius * Math.sin(angle)));
|
|
166
150
|
angle += direction * dangle;
|
|
167
151
|
}
|
|
168
|
-
points.push(pool.pull("
|
|
152
|
+
points.push(pool.pull("Point", x + radius * Math.cos(endAngle), y + radius * Math.sin(endAngle)));
|
|
169
153
|
}
|
|
170
154
|
|
|
171
155
|
/**
|
|
172
156
|
* adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
|
|
173
|
-
* @name arcTo
|
|
174
|
-
* @memberof Path2D
|
|
175
157
|
* @param {number} x1 - the x-axis coordinate of the first control point.
|
|
176
158
|
* @param {number} y1 - the y-axis coordinate of the first control point.
|
|
177
159
|
* @param {number} x2 - the x-axis coordinate of the second control point.
|
|
@@ -200,7 +182,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
200
182
|
var tangent_point1 = [x1 + a[0] * adj_l, y1 + a[1] * adj_l];
|
|
201
183
|
var tangent_point2 = [x1 + b[0] * adj_l, y1 + b[1] * adj_l];
|
|
202
184
|
|
|
203
|
-
points.push(pool.pull("
|
|
185
|
+
points.push(pool.pull("Point", tangent_point1[0], tangent_point1[1]));
|
|
204
186
|
|
|
205
187
|
var bisec = [(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0];
|
|
206
188
|
var bisec_l = Math.sqrt(Math.pow(bisec[0], 2) + Math.pow(bisec[1], 2));
|
|
@@ -218,8 +200,6 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
218
200
|
/**
|
|
219
201
|
* adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
|
|
220
202
|
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
|
|
221
|
-
* @name ellipse
|
|
222
|
-
* @memberof Path2D
|
|
223
203
|
* @param {number} x - the x-axis (horizontal) coordinate of the ellipse's center.
|
|
224
204
|
* @param {number} y - the y-axis (vertical) coordinate of the ellipse's center.
|
|
225
205
|
* @param {number} radiusX - the ellipse's major-axis radius. Must be non-negative.
|
|
@@ -267,18 +247,16 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
267
247
|
var _y1 = radiusY * Math.sin(angle);
|
|
268
248
|
var _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
|
|
269
249
|
var _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
|
|
270
|
-
points.push(pool.pull("
|
|
250
|
+
points.push(pool.pull("Point", _x2, _y2));
|
|
271
251
|
angle += direction * dangle;
|
|
272
252
|
}
|
|
273
253
|
//var x1 = radiusX * Math.cos(endAngle);
|
|
274
254
|
//var y1 = radiusY * Math.sin(endAngle);
|
|
275
|
-
//points.push(pool.pull("
|
|
255
|
+
//points.push(pool.pull("Point", x + x1 * cos_rotation - y1 * sin_rotation, y + x1 * sin_rotation + y1 * cos_rotation));
|
|
276
256
|
}
|
|
277
257
|
|
|
278
258
|
/**
|
|
279
259
|
* creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
|
|
280
|
-
* @name rect
|
|
281
|
-
* @memberof Path2D
|
|
282
260
|
* @param {number} x - the x-axis coordinate of the rectangle's starting point.
|
|
283
261
|
* @param {number} y - the y-axis coordinate of the rectangle's starting point.
|
|
284
262
|
* @param {number} width - the rectangle's width. Positive values are to the right, and negative to the left.
|
|
@@ -294,8 +272,6 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
294
272
|
|
|
295
273
|
/**
|
|
296
274
|
* adds an rounded rectangle to the current path.
|
|
297
|
-
* @name roundRect
|
|
298
|
-
* @memberof Path2D
|
|
299
275
|
* @param {number} x - the x-axis coordinate of the rectangle's starting point.
|
|
300
276
|
* @param {number} y - the y-axis coordinate of the rectangle's starting point.
|
|
301
277
|
* @param {number} width - the rectangle's width. Positive values are to the right, and negative to the left.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.5.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,6 @@
|
|
|
13
13
|
constructor(x = 0, y = 0) {
|
|
14
14
|
/**
|
|
15
15
|
* the position of the point on the horizontal axis
|
|
16
|
-
* @public
|
|
17
16
|
* @type {Number}
|
|
18
17
|
* @default 0
|
|
19
18
|
*/
|
|
@@ -21,7 +20,6 @@
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* the position of the point on the vertical axis
|
|
24
|
-
* @public
|
|
25
23
|
* @type {Number}
|
|
26
24
|
* @default 0
|
|
27
25
|
*/
|
|
@@ -55,8 +53,6 @@
|
|
|
55
53
|
*/
|
|
56
54
|
/**
|
|
57
55
|
* return true if this point is equal to the given values
|
|
58
|
-
* @name equals
|
|
59
|
-
* @memberof Point
|
|
60
56
|
* @param {number} x
|
|
61
57
|
* @param {number} y
|
|
62
58
|
* @returns {boolean}
|
|
@@ -77,7 +73,6 @@
|
|
|
77
73
|
|
|
78
74
|
/**
|
|
79
75
|
* clone this Point
|
|
80
|
-
* @name clone
|
|
81
76
|
* @returns {Point} new Point
|
|
82
77
|
*/
|
|
83
78
|
clone() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v14.
|
|
2
|
+
* melonJS Game Engine - v14.5.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
|
|
@@ -208,9 +208,7 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
208
208
|
* @param {number} [y=x]
|
|
209
209
|
* @returns {Polygon} Reference to this object for method chaining
|
|
210
210
|
*/
|
|
211
|
-
scale(x, y) {
|
|
212
|
-
y = typeof (y) !== "undefined" ? y : x;
|
|
213
|
-
|
|
211
|
+
scale(x, y = x) {
|
|
214
212
|
var points = this.points;
|
|
215
213
|
var len = points.length;
|
|
216
214
|
for (var i = 0; i < len; i++) {
|
|
@@ -466,7 +464,6 @@ import { exports as earcutExports } from '../_virtual/earcut.js';
|
|
|
466
464
|
|
|
467
465
|
/**
|
|
468
466
|
* update the bounding box for this shape.
|
|
469
|
-
* @ignore
|
|
470
467
|
* @name updateBounds
|
|
471
468
|
* @memberof Polygon
|
|
472
469
|
* @returns {Bounds} this shape bounding box Rectangle object
|